GridView
我正在研究一个类来在 C# 中对我的 's 进行数据绑定......
我已经做到了,所以我的寻呼机可以工作,但不确定我将如何进行排序工作......到目前为止,我的代码如下所示:
public static class Binder
{
public class gridView {
public static void Bind(GridView grid, IList source, bool pager, bool sorting) {
grid.DataSource = source;
if (pager) {
grid.PageIndexChanging += new GridViewPageEventHandler(PageIndexChanging);
}
if (sorting) {
grid.Sorting += new GridViewSortEventHandler(Sorting);
}
grid.DataBind();
}
public static void PageIndexChanging(object sender, GridViewPageEventArgs e) {
if (sender != null) {
GridView GridView1 = sender as GridView;
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
}
public static void Sorting(object sender, GridViewSortEventArgs e) {
if (sender != null) {
GridView GridView1 = sender as GridView;
//What to do?
GridView1.DataBind();
}
}
}
}
我会像这样绑定一个gridview:Binder.gridView.Bind(MyGridView, MyDataSource, true, true);
但是我有点迷失了如何进行分类?