Click here to Skip to main content
15,615,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used an update panel to show latest records in gridview on click of button without the need to refresh the page.. the code is:

<asp:Button ID="Button1" runat="server" Text="Show"/>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
           <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
                <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />

            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />

the problem is: on click of button, the grid is not updated.. Any help???
Updated 8-Dec-20 2:40am

on your button you are not running any event_handler so only page_load and page life cycle events will occurs better to update data in page_load
Share this answer
Use triggers, When you click on button Gridview will update
    <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
Share this answer
CHill60 8-Dec-20 8:42am    
What - like the one defined in the original question that isn't working?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900