我正在尝试在页面的后端部分动态创建事件PageIndexChanging
,如下所示:
protected void Page_Load(object sender, EventArgs e)
{
GridView gw = new GridView();
gw.ID = "gwGroupPeopleByCity";
gw.PageSize = 20;
gw.AllowPaging = true;
gw.AllowSorting = true;
gw.AutoGenerateColumns = false;
gw.PageIndexChanging += ...;
...
}
公司应该像:
protected void gwGroupPeopleByCity_PageIndexChanging(Object sender, GridViewPageEventArgs e)
{ ... }
但是当我尝试将gwGroupPeopleByCity_PageIndexChanging
放入PageIndexChanging
属性时,它会给我一个错误。而且,它说gw
超出了范围(显然)。我该如何解决这些问题?谢谢大家。
答案 0 :(得分:0)
为什么不在PageIndexChanging事件中尝试这个?
var gw = sender as GridView;