在DataGrid2的"属性生成器"中选"分页",选"允许分页",设定页大小 .. 行
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
startIndex=e.NewPageIndex*DataGrid2.PageSize;
DataGrid2.CurrentPageIndex = e.NewPageIndex;
UpdateView();
}
private void UpdateView()
{
string strCmd=".....";
SqlConnection conn = new SqlConnection(strConn);
SqlDataAdapter da = new SqlDataAdapter(strCmd, conn);
DataSet ds = new DataSet();
da.Fill(ds, "MyTable");
DataGrid2.DataSource = ds.Tables["MyTable"].DefaultView;
DataGrid2.DataBind();
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
startIndex=e.NewPageIndex*DataGrid2.PageSize;
DataGrid2.CurrentPageIndex = e.NewPageIndex;
UpdateView();
}
private void UpdateView()
{
string strCmd=".....";
SqlConnection conn = new SqlConnection(strConn);
SqlDataAdapter da = new SqlDataAdapter(strCmd, conn);
DataSet ds = new DataSet();
da.Fill(ds, "MyTable");
DataGrid2.DataSource = ds.Tables["MyTable"].DefaultView;
DataGrid2.DataBind();
}
解决方案 »
- dropdownlist 三级或两级联动无刷新!
- 关于ASP.NET中使用一个JS效果
- ScriptManager.AsyncPostBackError 事件
- 如何在GridView中的最后一行写:合计:功能,高手进来指教!谢谢
- 在动态帮定数据源时AspxGridView的排序、分组等功能失效了,请求高手
- asp.net和oracle的链接!在线等,急
- asp.net mvc 菜单求助
- 这个问题不知道怎么做了,急,做出来马上结帖
- 多个文件同时上传,如何实现?
- 再请教一个dropdownlist的问题!
- 现已做好一个在线购物程序,放到网上如何才能推广这个网站,
- .net 编译错误 C#编译器地址报错
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
UpdateView();
}
}
DataGrid2.CurrentPageIndex = e.NewPageIndex
DataGrid2.DataSource=..... //加这里
DataGrid2.DataBind()
这里的myReader是什么?是DataReader吗?如果DataSource是DataReader,那么必须使用自定义分页,即将AllowCustomPaging设为true。