EditColumn Events methods

K

kuljitsingh

Why e.Item.DataItem("datafield") does not works in EditCommand,
CancelCommand, and UpdateCommand whereas e.Item.Cells(12).Text works?
Is there a way to retreive datafields of a datagrid by their fieldnames
in these event methds???

Scorpius

Examnple -
Private Sub DataGrid123_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid123.EditCommand

e.Item.Cells(12).Text 'WORKS
e.Item.DataItem("datafield") ' DOES NOT WORKS
 
E

Elton Wang

Hi kuljitsingh,

e.Item.DataItem is from the datagrid's underlying data
source, whereas e.Item.Cells(index) is a cell of datagrid
itself. When postback datagrid's underlying data source is
gone (unless you save it in Session and retrieve it from
Session).

HTH

Elton Wang
(e-mail address removed)
 

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,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top