Refresh a GridView inside UserControl On Button Click in ASP.Net

Last Reply on Apr 09, 2013 08:57 AM By Mudassar

Posted on Apr 09, 2013 06:54 AM

I have a Page (created using master page) it has a UserControl and i want to reload the UserControl on button click (button in page outside the UserControl). I do not want to reload entire page. I want to reload just the UserControl.

ASPX:
 

<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger controlid="Button1" eventname="Click" />
        </Triggers>
            <ContentTemplate>
              
               
               
               
               <uc2:GetUserScraps ID="GetUserScraps1" runat="server" />
               
               
                
     </ContentTemplate>
        </asp:UpdatePanel>

I am not sure what to do on code behind.

Posted on Apr 09, 2013 08:57 AM

On Button click you will need to find rebind the GridView in UserControl. For that

1. Create a public void method in User Control

2. Write code to bind GridView with data

3. Call it as following on button click

UserControl1.BindGrid();