Murray Brown
asked on
ASP.net hide RadioButtonList items
Hi
I am using the following code to disable RadioButtonList items. Is it possible to hide them instead?
Private Sub GridView3_RowDataBound(sen der As Object, e As System.Web.UI.WebControls. GridViewRo wEventArgs ) Handles GridView3.RowDataBound
Try
' Required to ignore the header and footer rows
If e.Row.RowType = DataControlRowType.DataRow Then
Dim oNumberAnswers As String = CStr(e.Row.Cells(4).Text)
Dim rdb As RadioButtonList = DirectCast(e.Row.FindContr ol("RadioB uttonList1 "), RadioButtonList)
If oNumberAnswers = "2" Then
rdb.Items(2).Enabled = False
rdb.Items(3).Enabled = False
rdb.Items(4).Enabled = False
ElseIf oNumberAnswers = "3" Then
rdb.Items(3).Enabled = False
rdb.Items(4).Enabled = False
ElseIf oNumberAnswers = "4" Then
rdb.Items(4).Enabled = False
End If
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
I am using the following code to disable RadioButtonList items. Is it possible to hide them instead?
Private Sub GridView3_RowDataBound(sen
Try
' Required to ignore the header and footer rows
If e.Row.RowType = DataControlRowType.DataRow
Dim oNumberAnswers As String = CStr(e.Row.Cells(4).Text)
Dim rdb As RadioButtonList = DirectCast(e.Row.FindContr
If oNumberAnswers = "2" Then
rdb.Items(2).Enabled = False
rdb.Items(3).Enabled = False
rdb.Items(4).Enabled = False
ElseIf oNumberAnswers = "3" Then
rdb.Items(3).Enabled = False
rdb.Items(4).Enabled = False
ElseIf oNumberAnswers = "4" Then
rdb.Items(4).Enabled = False
End If
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
ASKER
Hi thanks Jesus. Where would I put this code? Thanks. Murray
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much
So you should be able to then programmatically assign it by specifying:
RadioButtonList.Items(1).C