求一个简单的asp.net分页代码或分页控件!
RT```请问gridview里德增删改功能还需要写代码设置吗?还有感觉datalist比gridview用起来比较灵活啊...
RT```
请问gridview里德增删改功能还需要写代码设置吗?
还有感觉datalist比gridview用起来比较灵活啊 展开
请问gridview里德增删改功能还需要写代码设置吗?
还有感觉datalist比gridview用起来比较灵活啊 展开
3个回答
展开全部
gridview自己就带分页啊,或者用datalist + datapager
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//分页代码
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
//绑定上次使用数据源
String cmdtext = "";
cmdtext = (String)this.ViewState["ds"];
Bind(cmdtext);
}
//我的绑定
protected void Bind(string sqlstr)
{
DataSet ds = data.get_dataset(sqlstr);
GridView1.DataSource = ds;
GridView1.AllowPaging = true;
GridView1.PagerSettings.Mode = PagerButtons.NextPreviousFirstLast;
GridView1.PagerSettings.NextPageText = "后页";
GridView1.PagerSettings.PreviousPageText = "前页";
GridView1.PagerSettings.FirstPageText = "首页";
GridView1.PagerSettings.LastPageText = "尾页";
GridView1.PageSize = 5;
GridView1.ShowFooter = true;
GridView1.DataSourceID = null;
GridView1.DataBind();
ViewState.Remove("ds");
ViewState.Add("ds", sqlstr);
}
应该可以直接用,自己改改就行
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
//绑定上次使用数据源
String cmdtext = "";
cmdtext = (String)this.ViewState["ds"];
Bind(cmdtext);
}
//我的绑定
protected void Bind(string sqlstr)
{
DataSet ds = data.get_dataset(sqlstr);
GridView1.DataSource = ds;
GridView1.AllowPaging = true;
GridView1.PagerSettings.Mode = PagerButtons.NextPreviousFirstLast;
GridView1.PagerSettings.NextPageText = "后页";
GridView1.PagerSettings.PreviousPageText = "前页";
GridView1.PagerSettings.FirstPageText = "首页";
GridView1.PagerSettings.LastPageText = "尾页";
GridView1.PageSize = 5;
GridView1.ShowFooter = true;
GridView1.DataSourceID = null;
GridView1.DataBind();
ViewState.Remove("ds");
ViewState.Add("ds", sqlstr);
}
应该可以直接用,自己改改就行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询