I have the following code which takes the selected items from a datalist and adds them to a database.
This code works however when it is adding the RoomType it is only adding the first character. So for Single its adding S only.
Any ideas why?
Thanks
Andrew
Code:
For Each li As DataListItem In dlProperties.Items
Dim cb As CheckBox = TryCast(li.FindControl("chkSelectRoom"), CheckBox)
Dim lblRoom As Label = TryCast(li.FindControl("RoomID"), Label)
Dim lblRoomType As Label = TryCast(li.FindControl("RoomTypeLabel"), Label)
Dim RoomID As Integer = Convert.ToInt32(lblRoom.Text)
Dim RoomType As String = Convert.ToString(lblRoomType.Text)
If cb IsNot Nothing Then
If cb.Checked Then
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@RoomID", RoomID.ToString())
cmd.Parameters.AddWithValue("@RoomType", RoomType.ToString())
cmd.ExecuteNonQuery()
TextBox1.Text += RoomType.ToString()
End If
End If
Next
This code works however when it is adding the RoomType it is only adding the first character. So for Single its adding S only.
Any ideas why?
Thanks
Andrew