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

时间:2022-12-23 02:01:18

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:

我正在尝试对我的DataGrid进行分页和排序,而DataGrid位于ModalPopupExtender中但我无法以任何方式对其进行分页,已经尝试使用 ,将UpdatePanel放在内部,外部,中间,并且它不起作用。模态弹出窗口不会关闭,但网格会消失。码:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Not Page.IsPostBack 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:

在Designer内部,这是代码h:

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

2 个解决方案

#1


1  

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.

汤米是对的,所以你要做的就是重新显示弹出窗口。在PageIndexChanging事件中的BindData()之后,再次使用弹出扩展器的Show()方法显示该面板。

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

这段代码在c#中,但几乎相同。

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

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

#2


0  

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.

如果您使用的是.NET AJAX工具包,请记住,每次单击某些内容(分页,排序等)时,页面都会执行回发,即使它看起来像AJAX-y。这意味着您每次都需要重新绑定数据。尝试删除页面加载中的IfPostback,看看它为您做了什么。

#1


1  

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.

汤米是对的,所以你要做的就是重新显示弹出窗口。在PageIndexChanging事件中的BindData()之后,再次使用弹出扩展器的Show()方法显示该面板。

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

这段代码在c#中,但几乎相同。

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

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

#2


0  

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.

如果您使用的是.NET AJAX工具包,请记住,每次单击某些内容(分页,排序等)时,页面都会执行回发,即使它看起来像AJAX-y。这意味着您每次都需要重新绑定数据。尝试删除页面加载中的IfPostback,看看它为您做了什么。