Paging related problems

F

Franck Diastein

Hi,

I have successfully set Paging in one of my DataGrids...

But I have a problem, when I use this code:

//************************** Code
private void dgMyDataGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) {

int _ID = -1;
_ID = int.Parse(dgMyDataGrid.DataKeys[e.Item.ItemIndex].ToString());

// My DB stuff using _ID

}
//************************** Code

When I load second page of DataGrid I have this error:

Index was out of range. Must be non-negative and less than the size of
the collection. Parameter name: index

And the 'wrong' line of code is:

_ID = int.Parse(dgMyDataGrid.DataKeys[e.Item.ItemIndex].ToString());

Any idea ?

TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top