I know this is an extremely basic question, but I couldn't find how to do this in VB... I have a CheckBoxList where one of the options includes a textbox to fill in your own value. So I need to have that textbox become enabled when its checkbox (a ListItem in the CheckBoxList) is checked. This is the code behind, I'm not sure what to put in my If statement to test if that certain ListItem is checked.
Protected Sub CheckBoxList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBoxList1.SelectedIndexChanged
If ___ Then
txtelect.Enabled = True
Else
txtelect.Enabled = False
End If
End Sub
Funtion to get them in a string
Assuming that your aspx look similar to this:
you can use the ListItem's-
Selected
property to check if your Textbox should be enabled:You can loop through the checkboxes in a CheckBoxList, checking each to see if it is checked. Try something like this:
The above code would be placed in the CheckBoxList's
SelectedIndexChanged
event handler.I wouldn't do it this way, it's very inefficient. You are hitting the server just to enable or disable a text box, you should use javascript. The code below would be better