ASP.NET GridView pagination without postback

你。 提交于 2020-01-03 17:33:13

问题


Just a quick question for all of you guys.

I have a Grid View inside Update Panel. My Modal PopUp pulls this Panel up. I am good so far.

However when I try to do pagination on the popped up grid view, The page Posts Back.

Then the Modal PopUp disappears and so does my GridView.

When I click on mybutton again, It shows the Modal PopUp with Grid View and the Next Page Contents in Grid View.

Is there any way I can get this Grid View to do pagination without Postback and without losing Modal PopUp ?

Any Help would be greatly appreciated.

Thanks,


回答1:


The page must post back each time you change the page of the GridView. However, you can emulate the desired functionality by hooking into the PageIndexChanged event of the GridView:

protected void GridView1_PageIndexChanged(object sender, EventArgs e)
{
    modalPopupExtender1.Show();
}



回答2:


You should have this layout:

<ModalPopup>
   <UpdatePanel>
       <GridView>
   <UpdatePanel>
</ModalPopup>

That way your ModalPopup won't disappear, unless you have another an outer updatepanel, and that updatepanel is set to UpdateMode=Always




回答3:


the popup should only dissappear when CancelControlID/OkControlID are clicked. More than 1 update panels can be a bit trickier.

Are you handling the page change event.

Private Sub Grid_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles Grid.PageIndexChanging
    Grid.PageIndex = e.NewPageIndex
    Grid.SelectedIndex = -1
    Grid.DataBind()
End Sub

This is not important ( from the point of this question), but your change you updateMode to Conditional.



来源:https://stackoverflow.com/questions/1724940/asp-net-gridview-pagination-without-postback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!