0
當我試圖轉到第2頁或數據網格中的任何其他後續頁面,它只是刷新頁面。
標記:
<!--Main DataGrid-->
<asp:DataGrid
ID="dgTasks"
runat="server"
PageSize="40"
AllowPaging="true"
AutoGenerateColumns="false"
ForeColor="#333333"
GridLines="Both"
Font-Size="Small"
AllowSorting="true"
OnItemDataBound="Item_DataBound" >
<HeaderStyle
BackColor="#990000"
Font-Bold="True"
ForeColor="White"
HorizontalAlign="Center"
Font-Size="Small"/>
<Columns>
...
</Columns>
<SelectedItemStyle
BackColor="#FFCC66"
Font-Bold="True"
ForeColor="Navy" />
<PagerStyle
BackColor="#CCCCCC"
ForeColor="#333333"
HorizontalAlign="Right"
Mode="NumericPages" />
<AlternatingItemStyle
BackColor="White" />
<ItemStyle
BackColor="#FFFBD6"
ForeColor="#333333" />
<FooterStyle
BackColor="#990000"
Font-Bold="True"
ForeColor="White" />
</asp:DataGrid>
代碼背後:
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
'DoNothing'
Else
BindData("")
End If
End Sub
Private Sub BindData(ByVal strDisplayCompleted As String, ByVal strSort As String)
Dim taskDataSet As TaskDataSet = New TaskDataSet()
Dim dt As DataTable = taskDataSet.GetData("N").Tables(0)
For Each dr As DataRow In dt.Rows
If dr.Item(2).ToString().StartsWith("Vacancy") Then
dr.Delete()
End If
Next
If strSort.Length > 0 Then
dt.DefaultView.Sort = strSort
End If
dgTasks.DataSource = dt.DefaultView
dgTasks.DataBind()
End Sub
Private Sub BindData(ByVal strSort As String)
BindData("N", strSort)
End Sub
現在,我甚至接近知道爲什麼分頁不工作。我有AllowPaging
等於true,我沒有重新綁定PostBack上的數據,所以我很困惑。任何幫助都會很棒。謝謝。
謝謝,我會試試看。 – XstreamINsanity 2011-02-04 16:48:09