Accessing DataRow Items by Name in Edit/Update/Delete Event

M

Marc Eggenberger

Hi there.

I have a small problem with DataGrid in ASP.NET & C#.

In the ItemDataBound Event I can use the following code

DataRowView drvSE = (DataRowView)e.Item.DataItem;

and then I can use
drvSE["ColumnName"].ToString();
to get the acutal data.

But in the Edit/Update/Delete Events this does not work.
The upper event has a DataGridItemEventArgs and the 3 commands where
it's not working have a DataGridCommandEventArgs.
They also have a e.Item.DataItem but its always null.

How should I do this here?

accessing the data with
e.Item.Cells[2].Text
works, but I dont want to hardcode the Columns position. How should I do
it?
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top