为什么只有这样DataGrid才能分页?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim DS As New Data.DataSet()
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
Dim DS As New Data.DataSet()
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub
只有这样DataGrid才能分页,可我按.NET帮助文件中
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
这样就无法显示,这是为什么呢?????????????????
If Not Page.IsPostBack Then
Dim DS As New Data.DataSet()
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
Dim DS As New Data.DataSet()
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub
只有这样DataGrid才能分页,可我按.NET帮助文件中
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
这样就无法显示,这是为什么呢?????????????????
...全文
请发表友善的回复…
发表回复
bluefish922 2002-06-26
- 打赏
- 举报
Dim DS As New Data.DataSet()
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
If Not Page.IsPostBack Then
DataGrid1.DataBind()
End If
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
If Not Page.IsPostBack Then
DataGrid1.DataBind()
End If
bluefish922 2002-06-26
- 打赏
- 举报
Dim DS As New Data.DataSet()
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
If Not Page.IsPostBack Then
DataGrid1.DataBind()
End If
只把绑定放在里面。
OleDbDataAdapter1.Fill(DS, "PL")
DataGrid1.DataSource = DS.Tables("PL")
If Not Page.IsPostBack Then
DataGrid1.DataBind()
End If
只把绑定放在里面。
softbunny 2002-06-26
- 打赏
- 举报
是“If Not Page.IsPostBack Then”在搞鬼,它让你的数据源在回发时不再次绑定。
去掉它后就可以了。
去掉它后就可以了。
xhan2000 2002-06-26
- 打赏
- 举报
因为每次都要绑定
可以使用cache
可以使用cache
plblackeagle 2002-06-26
- 打赏
- 举报
up
hgknight 2002-06-25
- 打赏
- 举报
去掉
If Not Page.IsPostBack Then
就可以想帮助写的一样了
If Not Page.IsPostBack Then
就可以想帮助写的一样了
juqiang 2002-06-25
- 打赏
- 举报
因为每次page_load的时候,datasource都没有了,所以,你要重新指定一下。