asp.net repeater控件分页显示数据 很辣手!高手来帮帮我!
第一次加载页面时可以,但点击下一页时,就出问题了!如:共:1/2页变成:共:2/1页,应该是2/2页,而且没有任何数据显示!代码:DimidAsInteger=Reque...
第一次加载页面时可以,但点击下一页时,就出问题了!如:共:1/2页变成: 共:2/1页,应该是2/2页,而且没有任何数据显示!
代码:
Dim id As Integer = Request("id")
comdstr = "select * from bbs where tyid=" & id
comd = New SqlClient.SqlCommand(comdstr, objconn)
objconn.Open()
adp = New SqlClient.SqlDataAdapter
adp.SelectCommand = comd
ds = New DataSet
adp.Fill(ds, "mingxi")
Dim pd As System.Web.UI.WebControls.PagedDataSource = New PagedDataSource
pd.DataSource = ds.Tables("mingxi").DefaultView()
pd.AllowPaging = True
pd.PageSize = 10
Dim CurPage As Integer
If Not Request.QueryString("Page") Is Nothing Then
CurPage = Convert.ToInt32(Request.QueryString("Page"))
Else
CurPage = 1
End If
pd.CurrentPageIndex = CurPage - 1
lblCurrentPage.Text = " 共:" & CurPage.ToString() & "/" & pd.PageCount & "页 "
If Not pd.IsFirstPage Then
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage - 1)
lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=1"
End If
If Not pd.IsLastPage Then
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage + 1)
lnkLast.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & pd.PageCount
End If
Repeater1.DataSource = pd
Repeater1.DataBind()
objconn.Close()
注:comdstr = "select * from bbs where tyid=" & id 将它的条件直接指定一个ID:如:comdstr = "select * from bbs where tyid=1"
正常,没有任何问题!
求救!一个菜鸟!希望各位前辈指点下迷津! 展开
代码:
Dim id As Integer = Request("id")
comdstr = "select * from bbs where tyid=" & id
comd = New SqlClient.SqlCommand(comdstr, objconn)
objconn.Open()
adp = New SqlClient.SqlDataAdapter
adp.SelectCommand = comd
ds = New DataSet
adp.Fill(ds, "mingxi")
Dim pd As System.Web.UI.WebControls.PagedDataSource = New PagedDataSource
pd.DataSource = ds.Tables("mingxi").DefaultView()
pd.AllowPaging = True
pd.PageSize = 10
Dim CurPage As Integer
If Not Request.QueryString("Page") Is Nothing Then
CurPage = Convert.ToInt32(Request.QueryString("Page"))
Else
CurPage = 1
End If
pd.CurrentPageIndex = CurPage - 1
lblCurrentPage.Text = " 共:" & CurPage.ToString() & "/" & pd.PageCount & "页 "
If Not pd.IsFirstPage Then
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage - 1)
lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=1"
End If
If Not pd.IsLastPage Then
lnkNext.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & Convert.ToString(CurPage + 1)
lnkLast.NavigateUrl = Request.CurrentExecutionFilePath & "?Page=" & pd.PageCount
End If
Repeater1.DataSource = pd
Repeater1.DataBind()
objconn.Close()
注:comdstr = "select * from bbs where tyid=" & id 将它的条件直接指定一个ID:如:comdstr = "select * from bbs where tyid=1"
正常,没有任何问题!
求救!一个菜鸟!希望各位前辈指点下迷津! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询