开发者

ModalPopupExtender + ASP.NET AJAX: Can't page grid

I'm trying to page and sort my DataGrid which is inside a ModalPopupExtender but I can't page it in any way, already tried with <Triggers>, put the UpdatePanel inside, outside, in the middle, and it does NOT work. Modal popup does not get closed but the grid just disappears. Code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Not Page.IsPostBack 开发者_JS百科Then
    BindData()
  End If
End Sub
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  SqlServerDS.SelectCommand = "SELECT * FROM emp WHERE name LIKE '%" & txtSearchName.Text & "%'"
  BindData()
End Sub
Private Sub BindData()
  grdSearch.DataSource = SqlServerDS
  grdSearch.DataBind()
End Sub

Private Sub grdBuscaPaciente_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdSearch.PageIndexChanging
  grdSearch.PageIndex = e.NewPageIndex
  BindData()
End Sub

Inside the Designer, this is the code h:

<modalpopupextender>
</modalpopupextender>
<panel>
<updatepanel>
<gridview>
</gridview>
</updatepanel>
</panel>


Tommy is right, so what you just have to do is re-show the popup. After the BindData() in the PageIndexChanging event show the panel again with the Show() method of the popup extender.

This code is in c# but is pretty much the same.

gvHorarioPB.DataSource = (DataTable)Session["Prueba"];
gvHorarioPB.PageIndex = e.NewPageIndex;
gvHorarioPB.DataBind();

//mpePB is my modalpopupextender
this.mpePB.Show();


If you are using the .NET AJAX toolkit, keep in mind that each time you click someting (paging, sorting, etc.), the page performs a postback, even if it looks AJAX-y. Meaning that you will need to rebind the data each time. Try removing the IfPostback in your page load and see what that does for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜