为什么我做的分页程序不能回到第一页呢?

goldbrighten 2002-12-29 06:27:15
我用datagrid和 sqldataadapter做的分页程序,可以跳到第二页去,但是不能回来,不知道为什么,奇怪啊!程序如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


SubMenuID = CInt(Request.Params("SubMenuID"))
If (Not IsPostBack) Then
BindData()
End If



End Sub

Private Sub BindData()
Dim ds As New DataSet()
Dim dt As New DataTable()
Dim mySqlDataAdapter As SqlDataAdapter
Dim tables As New KJ.TableDB()
Dim name As String

name = tables.GetTableName(SubMenuID)
mySqlDataAdapter = tables.GetTable(name)
mySqlDataAdapter.Fill(ds, "dd")
dt = ds.Tables("dd")
TableGrid.DataSource = ds.Tables("dd")
TableGrid.DataBind()
End Sub




Private Sub TableGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles TableGrid.PageIndexChanged
TableGrid.CurrentPageIndex = e.NewPageIndex
BindData()
End Sub
...全文
42 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yohomonkey 2002-12-29
  • 打赏
  • 举报
回复
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SubMenuID = CInt(Request.Params("SubMenuID"))
If (Not IsPostBack) Then
BindData()
End If
End Sub

Private Sub BindData()
Dim ds As New DataSet()
Dim dt As New DataTable()
Dim mySqlDataAdapter As SqlDataAdapter
Dim tables As New KJ.TableDB()
Dim name As String

name = tables.GetTableName(SubMenuID)
mySqlDataAdapter = tables.GetTable(name)
mySqlDataAdapter.Fill(ds, "dd")
session("dd") = ds.Tables("dd")
TableGrid.DataSource = session("dd")
TableGrid.DataBind()
End Sub

Private Sub TableGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles TableGrid.PageIndexChanged
TableGrid.CurrentPageIndex = e.NewPageIndex
TableGrid.DataSource = session("dd")
TableGrid.DataBind()
End Sub
yohomonkey 2002-12-29
  • 打赏
  • 举报
回复
Private Sub BindData()
Dim ds As New DataSet()
Dim dt As New DataTable()
Dim mySqlDataAdapter As SqlDataAdapter
Dim tables As New KJ.TableDB()
Dim name As String

name = tables.GetTableName(SubMenuID)
mySqlDataAdapter = tables.GetTable(name)
mySqlDataAdapter.Fill(ds, "dd")
dt = ds.Tables("dd")
TableGrid.DataSource = ds.Tables("dd")
TableGrid.DataBind()
End Sub
这种写法不对!
kimmnig 2002-12-29
  • 打赏
  • 举报
回复
程序好像没有问题,你要重新做个页面吧,在写上程序
goldbrighten 2002-12-29
  • 打赏
  • 举报
回复
<table cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td><asp:datagrid id="TableGrid" SelectedIndex="0" ShowHeader="False" BorderWidth="1px" BackColor="White" BorderStyle="None" BorderColor="#3366CC" Width="611px" CellPadding="4" runat="server" AllowPaging="True" PageSize="12" Height="253px">
<SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedItemStyle>
<ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#CCCCFF" BackColor="#003399"></HeaderStyle>
<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>
<PagerStyle HorizontalAlign="Left" ForeColor="#003399" BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
</asp:datagrid></td>
</tr>
</table>
xhan2000 2002-12-29
  • 打赏
  • 举报
回复
使用什么分页方式?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧