e.item.dataitem

A

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
 
A

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
 

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

Forum statistics

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

Latest Threads

Top