• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Radio button check and on check

Hi Experts,

I have a radio button in side my gridview control.
<asp:radiobutton ID="RBShowManu" runat="server"  AutoPostBack="true" >asp:radiobutton>

When I click the radio button it checked it. When I click the next radio button it checked the other one too. What can I do to check only one radio button at a time. I am using ASP.NET and VB.NET

Thank you
0
RadhaKrishnaKiJaya
Asked:
RadhaKrishnaKiJaya
  • 3
  • 2
1 Solution
 
CamilliaCommented:
You need a "groupname"

Like this
<asp:radiobutton ID="RBShowManu" runat="server" GroupName="showmenu"  AutoPostBack="true" >asp:radiobutton>

<asp:radiobutton ID="SecondRBShowManu" runat="server" GroupName="showmenu"  AutoPostBack="true" >asp:radiobutton>
0
 
RadhaKrishnaKiJayaAuthor Commented:
Thank you for your reply. I changed it but still it is selecting all the radio buttons when I click. I want to select only one radio button which I click.
0
 
CamilliaCommented:
Post your code
0
 
RadhaKrishnaKiJayaAuthor Commented:
Thank you for trying to help me. But its working now. I used the following code.

 Protected Sub GridView_RadioButton_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        deselect_RB_in_gridview()
        Dim SenderRB As RadioButton = sender
        'SenderRB.Checked = True
        Dim gvr As GridViewRow = SenderRB.NamingContainer
        Dim rb As RadioButton = CType(GVViewParts.Rows(gvr.RowIndex).FindControl("RBShowManu"), RadioButton)
        rb.Checked = True
end sub


Sub deselect_RB_in_gridview()
        Dim gvr As GridViewRow
        Dim i As Int32
        'deselect all radiobutton in gridview
        For Each gvr In GVViewParts.Rows
            Dim rb As RadioButton
            rb = CType(GVViewParts.Rows(i).FindControl("RBShowManu"), RadioButton)
            rb.Checked = False
            i += 1
        Next
    End Sub
0
 
RadhaKrishnaKiJayaAuthor Commented:
I found the solution. Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now