asp.net 想问一下aspnetpager控件这样写有没有实现存储过程分页
代码如下:page_load事件里面conn.Open()IfPage.IsPostBack=FalseThenDimsql2AsString="selectcount(...
代码如下
:page_load事件里面
conn.Open()
If Page.IsPostBack = False Then
Dim sql2 As String = "select count(*) from riji"
Dim cmd2 As New OleDbCommand(sql2, conn)
AspNetPager1.RecordCount = cmd2.ExecuteScalar()
Dim sql1 As String = "select * from riji "
Dim cmd1 As New OleDbCommand(sql1, conn)
Dim oda1 As New OleDbDataAdapter(cmd1)
Dim ds1 As New DataSet()
oda1.Fill(ds1, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "riji")
DataList1.DataSource = ds1
DataList1.DataBind()
End If
conn.Close()
aspnetpageer1_changer事件如下:
Protected Sub AspNetPager1_PageChanging(ByVal src As Object, ByVal e As Wuqi.Webdiyer.PageChangingEventArgs)
AspNetPager1.CurrentPageIndex = e.NewPageIndex
conn.Open()
Dim sql1 As String = "select * from riji "
Dim cmd1 As New OleDbCommand(sql1, conn)
Dim oda1 As New OleDbDataAdapter(cmd1)
Dim ds1 As New DataSet()
oda1.Fill(ds1, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "riji")
DataList1.DataSource = ds1
DataList1.DataBind()
conn.Close()
End Sub
已经可以实现分页 但是我的这种方法好像不是存储过程分页。
oda1.Fill(ds1, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "riji")
这句话的意思是每次都只从ds1里面拿取aspnetpager1.pagesize条数据吗?
每次都只消耗aspnetpager1.pagesize条数据流量吗? 展开
:page_load事件里面
conn.Open()
If Page.IsPostBack = False Then
Dim sql2 As String = "select count(*) from riji"
Dim cmd2 As New OleDbCommand(sql2, conn)
AspNetPager1.RecordCount = cmd2.ExecuteScalar()
Dim sql1 As String = "select * from riji "
Dim cmd1 As New OleDbCommand(sql1, conn)
Dim oda1 As New OleDbDataAdapter(cmd1)
Dim ds1 As New DataSet()
oda1.Fill(ds1, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "riji")
DataList1.DataSource = ds1
DataList1.DataBind()
End If
conn.Close()
aspnetpageer1_changer事件如下:
Protected Sub AspNetPager1_PageChanging(ByVal src As Object, ByVal e As Wuqi.Webdiyer.PageChangingEventArgs)
AspNetPager1.CurrentPageIndex = e.NewPageIndex
conn.Open()
Dim sql1 As String = "select * from riji "
Dim cmd1 As New OleDbCommand(sql1, conn)
Dim oda1 As New OleDbDataAdapter(cmd1)
Dim ds1 As New DataSet()
oda1.Fill(ds1, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "riji")
DataList1.DataSource = ds1
DataList1.DataBind()
conn.Close()
End Sub
已经可以实现分页 但是我的这种方法好像不是存储过程分页。
oda1.Fill(ds1, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "riji")
这句话的意思是每次都只从ds1里面拿取aspnetpager1.pagesize条数据吗?
每次都只消耗aspnetpager1.pagesize条数据流量吗? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询