I'm using VS2005 ASP.NET, and I have a page with a GridView. In code behind, in the page load event, a method of one class is called and return a datatble, and this datatable is assigned to the datasource property of the gridview. Then databind is called.
The autogeneratecolumns is set to true. The returned datatable used as datasource have 13 columns, but only 6 shoud be showed in the gridview. So, I coded the "GridView1_RowDataBound" event and customized the cells of the grid and the headers text.
Everithing is working fine, until I set the paging property to true. When I try to use paging, a error occurs with the message :
"Argument out of valid range. Parameter: index
in System.Web.UI.ControlCollection.get_Item(Int32 index) in System.Web.UI.WebControls.TableCellCollection.get_Item(Int32 index)"
This error occurs inside the "GridView1_RowDataBound" event, but just occurs when I set pagging to true. If I set pagging to False everything works fine.
How can I fix this error ? I have to code the "GridView1_RowDataBound" event to customize my columns and headers because I set datasource by code ( a datatable returned by a class method ). But this error occurs inside the event when I try to use paging.
Can anyone help me please ?
Thanks in advance