5

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,

4 Answers4

3

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();
}
Matthew Jones
  • 25,644
  • 17
  • 102
  • 155
0

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

aquinas
  • 23,318
  • 5
  • 58
  • 81
  • I have ModalPopUpExtender and I do not see any UpdatePanel inside it. What I have is as follows: .... –  Nov 12 '09 at 21:13
  • That looks correct. Do you have another update panel that is a parent of your modal popup? – aquinas Nov 13 '09 at 16:30
0

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.

VMAtm
  • 27,943
  • 17
  • 79
  • 125
ssingh3
  • 125
  • 1
  • 8
0

I hope this is helpful to someone, Matthew Jones answer worked for me, If you have grid view inside user control and the parent aspx page has the ModalPopupExtender use OnPageIndexChanged of the grid view

protected void gvAccountSearch_PageIndexChanged(object sender, EventArgs e)
{
    try
    {
        var popup = Parent.FindControl("mdlAccount") as ModalPopupExtender;
        if (popup != null)
            popup.Show();
    }
    catch (Exception)
    {
    }
}
Vishnu Babu
  • 1,183
  • 1
  • 13
  • 37