Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Gridview pageindex change event gets fire but its not refresh the grid values,
-Gridview is in modal pop up, therefore i dont want to refresh whole page.



-----------------Code behind------------

Protected Sub gvEmployeeList_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
gvEmployeeList.PageIndex = e.NewPageIndex
bindEmployeeGrid_More()

UpdatePanel1.Update()
End Sub

What I have tried:

I tried almost everything. I tried many option available with update panel and gridview properties.
Posted
Updated 11-Apr-19 8:42am
Comments
Vincent Maverick Durano 11-Apr-19 13:46pm    
How are you binding the GridView on initial load?

1 solution

Try to do the following:

1. Remove the ChildrenAsTrigger="false" in your UpdatePanel.
2. Remove the <trigger> declaration.
3. Remove the UpdatePanel1.Update() method.

The basic idea is to just wrap your GridView and Modal declaration inside UpdatePanel control. For example:

ASP.NET
<asp:Button ID="hiddenButton" runat="server" Text="" style="display:none;" />
    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" Enabled="True" TargetControlID="hiddenButton" PopupControlID="upModal" BehaviorID="modalbehavior" BackgroundCssClass="modalBackground"  OnCancelScript="cancelClick();" CancelControlID="closePopup">
    </ajaxToolkit:ModalPopupExtender>

    <asp:UpdatePanel runat="server" ID="upModal" UpdateMode="Conditional">
        <ContentTemplate>

            <asp:Panel id="pnlPopup" runat="server" class="ModalPanel" >

                <table cellpadding="5" cellspacing="5" class="topBanner" style="width:100%;">
                    <tr>
                        <td width="50">
                            <asp:LinkButton ID="closePopup" runat="server" onclick="LinkButton1_Click" CssClass="ClosePopupCls">Close 
                            [x]</asp:LinkButton>
                        </td>
                        <td align="center">
                            <asp:Label ID="lbl" runat="server" Text="Status"></asp:Label>
                        </td>
                        <td width="25">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <asp:GridView ID="gvRecords" runat="server" AllowPaging="True" 
                                BackColor="White" EmptyDataText="No Record Found" 
                                EnableSortingAndPagingCallbacks="True" ForeColor="GrayText" Height="600" 
                                onpageindexchanging="gvRecords_PageIndexChanging" Width="800">
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
            </asp:Panel>

        </ContentTemplate>
    </asp:UpdatePanel>


Then to open the GridView, you could do something like this (Note that this is in C#):

C#
protected void btnShowGridView_Click(object sender, EventArgs e)
{
    ModalPopupExtender1.Show();
    BindData();
}


Your PageIndexChanging event would be like this:

C#
protected void gvRecords_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvRecords.PageIndex = e.NewPageIndex;
    BindData();
}
 
Share this answer
 

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