PageIndexChanging编程方法

时间:2014-04-17 16:08:44

标签: c# asp.net gridview

我正在尝试在页面的后端部分动态创建事件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超出了范围(显然)。我该如何解决这些问题?谢谢大家。

1 个答案:

答案 0 :(得分:0)

为什么不在PageIndexChanging事件中尝试这个?

var gw = sender as GridView;