R
Ryan Rueckl
Hello,
It seems that no matter what I do, I cannot get paging working on my
datagrid. I'll try to explain as best as I can how my program behaves. I
did build the datagrid properties in the designer first, not at runtime,
including the bound columns I use. I have it set to allow paging with 25
pages. I then went into the events, named the PageIndexChanged event
('PageChange'), and double click the event to load it into the code. It
looks as if it is loaded fine - in InitializeComponent there is
this.DataGrid1.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.PageChange);
and there is the corresponding method at the end of the class.
I also have a seperate class 'DataSource' - the constructor creates a new
empty dataset. It has a Refresh method that gets called when the page gets
updated (also when it loads) that adds a table to the dataset by calling a
GetAccounts method which returns a datatable. In this GetAccounts method is
where i build the datatable with columns that match the bound columns of the
datagrid and populate the table with my data.
When the program first starts, its creates an instance of the DataSource
class. When the page load method is called, if it's not a postback it calls
an update function, which calls the DataSource Refresh method and then binds
the datagrid to the dataset built in DataSource instance.
I know it sounds complicated but is based off a Microsoft example. Without
paging works great - all the data shows up. When i turn the paging on, the
first page with 25 rows shows up, but when I click the > Next arrow, the
datagrid disappears. I put a stop/breakpoint in the PageChange method to
see if it ever even gets called and it doesn't. I also put a different stop
point in the page load function and notice the all my data previously in the
grid source is gone, even though I have EnableViewState set to true.
Anybody have any ideas? I really thought datagrids would be a little more
straightforward than this. It is quite frustrating.
Thanks,
Ryan
It seems that no matter what I do, I cannot get paging working on my
datagrid. I'll try to explain as best as I can how my program behaves. I
did build the datagrid properties in the designer first, not at runtime,
including the bound columns I use. I have it set to allow paging with 25
pages. I then went into the events, named the PageIndexChanged event
('PageChange'), and double click the event to load it into the code. It
looks as if it is loaded fine - in InitializeComponent there is
this.DataGrid1.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.PageChange);
and there is the corresponding method at the end of the class.
I also have a seperate class 'DataSource' - the constructor creates a new
empty dataset. It has a Refresh method that gets called when the page gets
updated (also when it loads) that adds a table to the dataset by calling a
GetAccounts method which returns a datatable. In this GetAccounts method is
where i build the datatable with columns that match the bound columns of the
datagrid and populate the table with my data.
When the program first starts, its creates an instance of the DataSource
class. When the page load method is called, if it's not a postback it calls
an update function, which calls the DataSource Refresh method and then binds
the datagrid to the dataset built in DataSource instance.
I know it sounds complicated but is based off a Microsoft example. Without
paging works great - all the data shows up. When i turn the paging on, the
first page with 25 rows shows up, but when I click the > Next arrow, the
datagrid disappears. I put a stop/breakpoint in the PageChange method to
see if it ever even gets called and it doesn't. I also put a different stop
point in the page load function and notice the all my data previously in the
grid source is gone, even though I have EnableViewState set to true.
Anybody have any ideas? I really thought datagrids would be a little more
straightforward than this. It is quite frustrating.
Thanks,
Ryan