| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 564 人关注过本帖
标题:[求助]关于datagrid的分页问题(困惑中)!
取消只看楼主 加入收藏
uestcsd
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-5-9
收藏
 问题点数:0 回复次数:2 
[求助]关于datagrid的分页问题(困惑中)!

请教各位,为什么我点击第二页时或点击下载按钮时,datagrid就消失了?请问哪里出错了?谢谢!!!而且要保证取值的正确性。
代码如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


If Not IsPostBack Then
datagrid1.DataSource = CreateDataSource()
'datagrid1.DataSource = dv
datagrid1.DataBind()
End If
End Sub
Function CreateDataSource() As ICollection
Dim dt As New DataTable
Dim dr As DataRow

dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))

Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dt.Rows.Add(dr)
Next i

Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource
Sub detailsClicked(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Try
Dim buttonColumn As TableCell = e.Item.Cells(1)
Dim buttonColText As String = buttonColumn.Text
TextBox1.Text = buttonColText
Catch ex As Exception
End Try
End Sub
Private Sub datagrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles datagrid1.PageIndexChanged
datagrid1.CurrentPageIndex = e.NewPageIndex
datagrid1.DataBind()
End Sub


<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<ASP:DATAGRID id="datagrid1" runat="server" Font-Size="8pt" Width="80%" BorderColor="Tan" BorderWidth="1px"
BackColor="LightGoldenrodYellow" CellPadding="2" GridLines="None" OnItemCommand="detailsClicked"
showfooter="True" AllowSorting="True" PagerStyle-PageButtonCount="10" HorizontalAlign="Center"
EnableViewState="False" HeaderStyle-BackColor="#aaaadd" Font-Name="Verdana" Font-Names="Verdana"
ForeColor="Black" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages">
<SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedItemStyle>
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
<FooterStyle BackColor="Tan"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="下载" ButtonType="PushButton" CommandName="details"></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" ForeColor="#003399" BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
</ASP:DATAGRID>
<asp:TextBox id="TextBox1" runat="server" Width="168px"></asp:TextBox>
</form>
</body>

搜索更多相关主题的帖子: datagrid 困惑 Load Sub ByVal 
2006-05-12 13:23
uestcsd
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-5-9
收藏
得分:0 
EnableViewState原来就是true
问题的关键是我想在翻页后,正确取值,请问改如何修改?
2006-05-15 10:14
uestcsd
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-5-9
收藏
得分:0 
我改成
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


'If Not IsPostBack Then
datagrid1.DataSource = CreateDataSource()
'datagrid1.DataSource = dv
datagrid1.DataBind()
'End If
End Sub
可以进入第二页了
但是为什么我点击第二页的第n行下载按钮时,取得的数值却是第一页的第n行的数值???

2006-05-15 14:11
快速回复:[求助]关于datagrid的分页问题(困惑中)!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035989 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved