Editing a row in a datagrid

G

Guest

I have coded an updatable datagrid and can’t seem to obtain the original
value from the cell in order to run an update on the database. I can obtain
the (new) value typed by the user (see DataGrid1_Update), but I also need the
original/old value. How can I obtain it?

void DataGrid1_Edit(object sender, DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = (int) e.Item.ItemIndex;
ddlTransmissionName_SelectedIndexChanged(sender, (System.EventArgs) e);
}

void DataGrid1_Update(object sender, DataGridCommandEventArgs e)
{
System.Web.UI.WebControls.TextBox tbFieldName = new TextBox();
tbFieldName = e.Item.FindControl("txtFieldName") as
System.Web.UI.WebControls.TextBox;
string sFieldName = tbFieldName.Text;

DataGrid1.EditItemIndex = -1;
ddlTransmissionName_SelectedIndexChanged(sender, (System.EventArgs) e);
}
 
E

Elton W

Hi Mareal,

You can save the datagrid's data source, e.g. datatable
(original/old value), in Session or Context object. Then
in Update method retrieve corresponding value from the
data source.

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top