Home All Groups Group Topic Archive Search About
Author
9 Mar 2005 3:05 PM
anonymous
hey,

    I have created a datalist and added some data into it,
via a dataset. Each row contains an +/- button, which has
a commandname associated to it. Now whenever somebody
presses the +/- button, I need to get the data from that
cell. For that I am using the ItemCommand, but
e.item.dataitem is always empty. How I am supposed to get
the data?

Any help is very appreciated.
Thanks

Author
10 Mar 2005 7:15 PM
Andrew Backer
AFAIK there will not be anything in dataItem when an event is posted.
It is used inside the xxx_ItemDataBound events while the display is
being built.

The event artgs has an ItemIndex property that indicated which row was
clicked.  You can use this to read the proper key and get the unique
identifier :

int rowNum = e.Item.ItemIndex;
string pKey = dgrid.DataKeys[ rowNum ].ToString();   

- Andrew Backer