Groups | Blog | Home
all groups > asp.net datagrid control > august 2004 >

asp.net datagrid control : Paging problem in VS.Net - datagrid disappears


Alan
8/31/2004 2:01:02 PM
I have a datagrid in VS.Net showing numeric paging and the first page of
data is displayed. Clicking on any other of the page numbers results in the
datagrid disappearing - no error message, but the entire datagrid is gone.
I have tried putting "AddHandler DataGrid1.PageIndexChanged, AddressOf
DataGrid_Page" in the page load to wire up the event (since
AutoEventWireup="false"). If I set a breakpoint in DataGrid_Page, it never
gets there.

Sub DataGrid_Page(ByVal sender As Object, ByVal e As
DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex

Get_Data() ' datagrid is bound again in get_data()

End Sub

I made a very similar type of datagrid page in WebMatrix and the paging
works fine.
In VS.Net I am having this strange problem.

Thanks
Alan


Alan
8/31/2004 2:22:53 PM
I found the solution.
I am adding the columns to the datagrid in code. They need to be added to
the datagrid on every page change.
Also that is insufficient. An initial empty column needs to be predefined
using the following in the grid definition:
<Columns>
<asp:BoundColumn></asp:BoundColumn>
</Column>

Now the paging works.

AddThis Social Bookmark Button