前台.aspx
排序
Allowsort = "true"
sortExpression = "ID"
DataView dv = SortBindGrid(dt);
#region排序
protected void FollowExamInfoGridView_Sorting(object sender, GridViewSortEventArgs e)
{
ViewState["sortexpression"] = e.SortExpression;
if (ViewState["sortdirection"] == null)
{
ViewState["sortdirection"] = "asc";
}
else
{
if (ViewState["sortdirection"].ToString() == "asc")
{
ViewState["sortdirection"] = "desc";
}
else
{
ViewState["sortdirection"] = "asc";
}
}
BindFollowExamInfoGridView(Convert.ToInt32(HiddenPersonID.Value));
}
public DataView SortBindGrid(DataTable table)
{
if (table != null)
{
DataView dv = table.DefaultView;
if (ViewState["sortexpression"] != null && ViewState["sortdirection"] != null)
{
dv.Sort = ViewState["sortexpression"].ToString() + " " + ViewState["sortdirection"].ToString();
}
return dv;
}
else
{
return null;
}
}
#endregion
=======自带分页
#region自带分页
protected void FollowExamInfoGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
FollowExamInfoGridView.PageIndex = e.NewPageIndex;
BindFollowExamInfoGridView(Convert.ToInt32(HiddenPersonID.Value));
}
#endregion
</div>
选中Grid View 的实现
if (e.Row.RowType ==
您可能想查找下面的文章:
- ASP.NET GridView的Bootstrap分页样式
- asp.net实现固定GridView标题栏的方法(冻结列功能)
- 在ASP.NET 2.0中操作数据之六十四:GridView批量添加数据
- 在ASP.NET 2.0中操作数据之六十三:GridView实现批量删除数据
- 在ASP.NET 2.0中操作数据之六十二:GridView批量更新数据
- 在ASP.NET 2.0中操作数据之五十一:从GridView的页脚插入新记录
- 在ASP.NET 2.0中操作数据之四十九:为GridView控件添加RadioButton
- 在ASP.NET 2.0中操作数据之二十八:GridView里的Button
- 在ASP.NET 2.0中操作数据之十五:在GridView的页脚中显示统计信息
- 在ASP.NET 2.0中操作数据之十二:在GridView控件中使用TemplateField