欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【asp.net的GridView控件使用方法大全】,下面是详细的讲解!
asp.net的GridView控件使用方法大全
#region分页
protected void BindFollowExamInfoGridView(int PersonID)
{
int currentpage=Convert.ToInt32(lblPage.Text);
DataTable dt=new DataTable();
dt=feibf.GetByPersonIDFollowExamInfo(PersonID); //查询指定人的随访信息记录
if (dt.Rows.Count > 0)
{
FollowExamInfoGridView.DataSource=dt;
FollowExamInfoGridView.DataBind();
PagedDataSource ps=new PagedDataSource();
ps.DataSource=dt.DefaultView;
ps.AllowPaging=true;
ps.PageSize=Convert.ToInt32(ddlPage.SelectedValue);
lblPageCount.Text=ps.PageCount.ToString();
this.lblPreButton.Enabled=true;
this.lblNextButton.Enabled=true;
ps.CurrentPageIndex=currentpage - 1;
if (currentpage==1)
{
this.lblPreButton.Enabled=false;
this.lblFirstButton.Enabled=false;
}
else
{
this.lblPreButton.Enabled=true;
this.lblFirstButton.Enabled=true;
}
if (currentpage==ps.PageCount)
{
this.lblNextButton.Enabled=false;
this.lblLastButton.Enabled=false;
}
else
{
this.lblNextButton.Enabled=true;
this.lblLastButton.Enabled=true;
}
FollowExamInfoGridView.DataSource=ps;
FollowExamInfoGridView.DataBind();
}
}
protected void lblPreButton_Click(object sender, EventArgs e)
{
this.lblPage.Text=Convert.ToString(Convert.ToUInt32(lblPage.Text) - 1);
BindFollowExamInfoGridView(Convert.ToInt32(Request.QueryString["PersonID"]));
}
protected void lblNextButton_Click(object sender, EventArgs e)
{
this.lblPage.Text=Convert.ToString(Convert.ToUInt32(lblPage.Text) + 1);
BindFollowExamInfoGridView(Convert.ToInt32(Request.QueryString["PersonID"]));
}
protected void lblFirstButton_Click(object sender, EventArgs e)
{
this.lblPage.Text="1";
BindFollowExamInfoGridView(Convert.ToInt32(Request.QueryString["PersonID"]));
}
protected void lblLastButton_Click(object sender, EventArgs e)
{
this.lblPage.Text=lblPageCount.Text;
BindFollowExamInfoGridView(Convert.ToInt32(Request.QueryString["PersonID"]));
}
protected void ddlPage_SelectedIndexChanged(object sender, EventArgs e)
{
lblPage.Text="1";
BindFollowExamInfoGridView(Convert.ToInt32(Request.QueryString["PersonID"]));
}
#endregion
排序
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
关于asp.net的GridView控件使用方法大全的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【服务器】asp.net页面状态管理cookie和服务器状
- 【Repeater控件】.NET实现Repeater控件+AspNetPag
- 【客户端】获取客户端IP地址c#/vb.net各自实现代
- 【asp】asp.net上传execl文件后 在页面上加载显示
- 【Excel】页面导出为Excel的时间格式的问题-时间
- 【ref】asp.net(c#)ref out params的区别-out-pa
- 【数据控件】asp.net获得数据控件事件索引并获取
- 【NET】10个.NET中删除空白字符串的方法-删除空白
- 【web】web.config配置连接字符串的方法-config配
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
