A
Alan Eilers
I have set up a DataGrid with default paging. The DG ItemCommand
works fine when user selects row by clicking on ButtonColumn (which
fills in text boxes at bottom of page). ItemIndex properly shows 0
when first row selected, 1 for second, etc. But when user clicks on
hyperlink for new page at bottom of DG, ItemIndex shows as -1 in
ItemCommand handler! If I don't trap it first I get an "index out of
range" error there when trying to access the values from the selected
line.
Questions: (1) Why does the selection of a page hyperlink fire
ItemCommand event before it fires PageIndexChanged? (2) Why doesn't
the ItemIndex default to 0 in ItemCommand instead of -1 (which I
specified in the SelectedIndex property of the DG)? (3) Why is it
important to establish any kind of row position in ItemCommand anyway
first, since my PageIndexChanged event happens next and goes to a new
page just fine?
Just some idiosyncracies of the DataGrid that make it a challenge for
newbies like me to learn. Any insights would be appreciated.
Alan Eilers
(e-mail address removed)
works fine when user selects row by clicking on ButtonColumn (which
fills in text boxes at bottom of page). ItemIndex properly shows 0
when first row selected, 1 for second, etc. But when user clicks on
hyperlink for new page at bottom of DG, ItemIndex shows as -1 in
ItemCommand handler! If I don't trap it first I get an "index out of
range" error there when trying to access the values from the selected
line.
Questions: (1) Why does the selection of a page hyperlink fire
ItemCommand event before it fires PageIndexChanged? (2) Why doesn't
the ItemIndex default to 0 in ItemCommand instead of -1 (which I
specified in the SelectedIndex property of the DG)? (3) Why is it
important to establish any kind of row position in ItemCommand anyway
first, since my PageIndexChanged event happens next and goes to a new
page just fine?
Just some idiosyncracies of the DataGrid that make it a challenge for
newbies like me to learn. Any insights would be appreciated.
Alan Eilers
(e-mail address removed)