locked
radiobutton not working inside update panel? RRS feed

  • Question

  • User1806930132 posted

    Hi

    why is this noty working

    I have the below code when I click yes/no radiobutton nothing happens,why?

     <tr><td><asp:ScriptManager runat="server"></asp:ScriptManager> <asp:UpdatePanel runat="server"><ContentTemplate>  on Site :  <asp:Radiobutton runat="server" ID="Radiobutton1" Text="Yes" AutoPostBack="true" GroupName="e1" OnCheckedChanged="Radiobutton1_CheckedChanged" /><asp:Radiobutton runat="server" Groupname="e1" autopostback="true" ID="Radiobutton2" Text="No" OnCheckedChanged="Radiobutton2_CheckedChanged"/></ContentTemplate></asp:UpdatePanel>
     Protected Sub Radiobutton1_CheckedChanged(sender As Object, e As EventArgs)
            GridView1.Visible = True
        End Sub
        Protected Sub Radiobutton2_CheckedChanged(sender As Object, e As EventArgs)
            GridView1.Visible = False
        End Sub



    Tuesday, May 10, 2016 11:56 AM

Answers

  • User475983607 posted

    By "not working", can I assume you mean the GridView is not hidden when clicking the radio button?

    The GridView must be in the Update panel with the radio button.  Update panels, by definition, only update the contents within the panel.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 10, 2016 12:05 PM
  • User527778624 posted

    Hi,

    I have the below code when I click yes/no radiobutton nothing happens,why?

    If you want gridview be visible and hide based on radio buttons, include Gridview also in UpdatePanel.

    Note: before showing gridview make sure you are adding the records to it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 10, 2016 12:08 PM

All replies

  • User475983607 posted

    By "not working", can I assume you mean the GridView is not hidden when clicking the radio button?

    The GridView must be in the Update panel with the radio button.  Update panels, by definition, only update the contents within the panel.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 10, 2016 12:05 PM
  • User527778624 posted

    Hi,

    I have the below code when I click yes/no radiobutton nothing happens,why?

    If you want gridview be visible and hide based on radio buttons, include Gridview also in UpdatePanel.

    Note: before showing gridview make sure you are adding the records to it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 10, 2016 12:08 PM
  • User61956409 posted

    Hi msaahil,

    Please try to set UpdateMode="Conditional" and call . Update() method to update UpdatePanel content.

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        Protected Sub Radiobutton1_CheckedChanged(sender As Object, e As EventArgs)
            GridView1.Visible = True
    
            UpdatePanel1.Update()
        End Sub
        Protected Sub Radiobutton2_CheckedChanged(sender As Object, e As EventArgs)
            GridView1.Visible = False
    
            UpdatePanel1.Update()
        End Sub
    

    Best Regards,

    Fei Han



    Wednesday, May 11, 2016 7:50 AM
  • User1806930132 posted

    Hello

    I tried the way u all said it works fine but I have more than 2 radiobuttons and gridviews

    so when I try to add another scriptmanager before UpdatePanel2...it shows error that only one script manager can be added on one page

    so what do I do?will just one script manager work for all updatepanels on a page?

    Wednesday, May 11, 2016 10:16 AM
  • User475983607 posted

    so when I try to add another scriptmanager before UpdatePanel2...it shows error that only one script manager can be added on one page

    You only need one script manager.  One script manager for each update panel is not required.

    so what do I do?will just one script manager work for all updatepanels on a page?

    This is a design issue that you must work through.

    Wednesday, May 11, 2016 10:25 AM