Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Editing a row in a datagrid

Reply
Thread Tools

Editing a row in a datagrid

 
 
=?Utf-8?B?bWFyZWFs?=
Guest
Posts: n/a
 
      05-02-2005
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);
}

 
Reply With Quote
 
 
 
 
Elton W
Guest
Posts: n/a
 
      05-02-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)


>-----Original Message-----
>I have coded an updatable datagrid and can?Tt 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);
>}
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to stop editing another row in a Gridview, ReorderList etc when another row is already being edited Andrew Jocelyn ASP .Net 2 04-27-2009 02:01 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Row / Column gets much bigger when editing a row in grid Bazza Formez ASP .Net 4 12-09-2004 11:03 PM
Problem getting DataRowView.DataItem when editing a DataGrid row Henri ASP .Net 0 08-03-2004 11:05 AM
Multi-row Editing in the ASP.NET DataGrid Alex ASP .Net 1 10-06-2003 03:39 AM



Advertisments