Monday, January 2, 2012

How to make single Selection of Radio Button in a Grid View using VB.net


Some time its happens in a Gridview have a column with more radio buttons but it do not select a single selection of a radio button. It selects all the radio buttons as you select it. For get Rid from this Problem. Given Below function can help you:


Protected Sub RdAdd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  Dim dr As GridViewRow
  Dim oldRow As RadioButton = GdvAdd.FindControl("rdadd")
  Dim count = 0
  'TextBox3667.Text = Request.Form("RDI")
  For Each dr In GdvAdd.RowsoldRow = CType(GdvAdd.Rows(count).FindControl("rdadd"),
RadioButton)oldRow.Checked = False
            count += 1
        Next
        'ADD Old Value
        Dim NewRow As RadioButton = sender
        Dim row As GridViewRow = NewRow.NamingContainer
        NewRow.FindControl("rdadd")
        NewRow.Checked = True
    End Sub

No comments:

Post a Comment