I have a Grid View inside the Update Panel. But when i change the page of Grid View, it post backs and refresh the page.
Here is my Asp.Net Control:
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvLeads" runat="server" AutoGenerateColumns="false" CssClass="mydatagrid" PagerStyle-CssClass="pager"
HeaderStyle-CssClass="header" RowStyle-CssClass="rows" AllowPaging="True" PageSize="2" ShowHeaderWhenEmpty="True" EmptyDataText="No Leads Found" PagerStyle-Mode="NumericPages" AllowSorting="True"
OnPageIndexChanging="gvLeads_PageIndexChanging" EnableSortingAndPagingCallbacks="true">
<Columns>
<asp:BoundField DataField="LeadId" HeaderText="Id" />
<asp:BoundField DataField="LeadTitle" HeaderText="Title" />
<asp:BoundField DataField="Date" HeaderText="Date" />
<asp:BoundField DataField="StatusTitle" HeaderText="Status" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpdateLeadMaster" />
<asp:AsyncPostBackTrigger ControlID="gvLeads" EventName="PageIndexChanging" />
</Triggers>
</asp:UpdatePanel>
And here is the Page Index Changing Event:
protected void gvLeads_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvLeads.PageIndex = e.NewPageIndex;
gvLeads.DataSource = dtLead;
gvLeads.DataBind();
}
Is there something wrong with my code? or whats causing this issue?
Grid view will work with update panel, only if the EnableSortingAndPagingCallbacks
is false
.
Hope this help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.