最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net中ListView与DataPager分页程序
时间:2022-06-25 03:49:21 编辑:袖梨 来源:一聚教程网
页面代码如下:
代码如下 | 复制代码 | ||||||||||||
onprerender="DataPager2_PreRender"> |
后台代码:
代码如下 | 复制代码 |
protected void DataPager2_PreRender(object sender, EventArgs e) { BindData(); } private void BindData() { using (OleDbConnection conn = new OleDbConnection(OleDbHelper.ConnectionString)) { string sql = "select * from studentscore"; OleDbDataAdapter dp=new OleDbDataAdapter(sql,conn); DataTable dt = new DataTable(); dp.Fill(dt); _simpleTableListView.DataSource = dt; _simpleTableListView.DataBind(); } } |
注意:使用本方法,不需要在页面的Page_Load事件中绑定数据到ListView控件,
否则分页会有问题。
第2种方法:
代码如下 | 复制代码 |
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } protected void _simpleTableListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) { DataPager2.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); BindData(); } |
相关文章
- 沙石镇时光肥料怎么合成-详细方法介绍 05-05
- 新版cex交易所app 05-05
- cex数字货币交易所 05-05
- pi币挖矿app2024最新版本 05-05
- cex交易平台app下载2024最新版 05-05
- 火必网app官网正版 05-05