473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Editing a row in a datagrid

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);
}

Nov 19 '05 #1
1 992
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
el********@hotmail.com

-----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);}

.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Swaroop | last post by:
Hi, I am using a Datagrid to populate the details given by a user in the footer of the datagrid.i am using an object array to populate the datagrid(a sample project so not using a database to...
4
by: TT (Tom Tempelaere) | last post by:
Hi, Suppose there is a DataGrid on a form bound to a DataTable. When a user is editing a cell without leaving the cell, and then closes the form, the value is not updated to the underlying data...
3
by: Islamegy | last post by:
When i press btn_save all changed rows in my grid get saved except the last editing row... I want my btn_Save to end editing in the datagrid.. so if user didn't press "enter" after editing last...
1
by: Blake Versiga | last post by:
When editing a datagrid (C#) I need to know if the user changed the value of cell AND what the previous value was. Is this possible? If so how do I get the previous value or at least if the...
0
by: Raterus | last post by:
Here is my only problem with using the datagrid to edit data. Say I have a moderate sized table, with about 15 columns. I want to allow a user to be able to edit most all of these fields, except...
9
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be...
1
by: MrMike | last post by:
I have a sub named Bind("") which binds my a datagrid on my webform. In order to enter edit mode and edit records on this datagrid, I must make a call to Bind("") either before or after I place...
5
by: Sharon | last post by:
I have a DataGrid on my Form, and I wish to disable any cell editing. For example; when the user clicks on a cell, the cell become editable by changing its color to gray and context menu is shown...
0
by: hanusoft | last post by:
This is an example of editing in DataGrid and Default Paging http://www.hanusoftware.com Html Design Code : - <asp:DataGrid id="DataGrid1" DataKeyField="id" runat="server" Height="224px"...
0
by: prerak_v_shah | last post by:
Hi, Friends, I have been developing datagrid program in .Net 1.1 and having VB.Net as a programming language. I have created a datagrid which is bound to a datatable as its datasource. It also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.