473,486 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Updating DataGrid while editing, doesn't update

I can't seem to get the update piece working properly while doing in-place editing. I don't receive any errors, but the update doesn't take place. From the examples I've used as "go bys" it looks pretty straight forward. I've included my update code below. If anyone has any insight into my problem, I would certainly appreciate it.

Thanks,
Jeff
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//load the dataset with the xml file
ds = new DataSet();

//load string with full path to xml file
string strFile = Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml";
//load the dataset with the xml file
ds.ReadXml (strFile, XmlReadMode.InferSchema);

string strDate = ((TextBox)(e.Item.Cells[2].Controls[0])).Text;
string strException = ((TextBox)(e.Item.Cells[3].Controls[0])).Text;
string strDuration = ((TextBox)(e.Item.Cells[4].Controls[0])).Text;

//get current row
DataRow dr = ds.Tables["exceptions"].Rows[e.Item.ItemIndex];
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.Tables["exceptions"].AcceptChanges();
ds.WriteXml (Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml");
DataGrid1.EditItemIndex = -1;
BindDataGrid();
}
Nov 17 '05 #1
1 1263
Hi Jeff!!

Check whether u r calling BindDataGrid() in onLoad event
also..Check postback conditions for the same!!

Hope it works..

Avneesh
-----Original Message-----
I can't seem to get the update piece working properly while doing in-place editing. I don't receive any errors,
but the update doesn't take place. From the examples I've
used as "go bys" it looks pretty straight forward. I've
included my update code below. If anyone has any insight
into my problem, I would certainly appreciate it.
Thanks,
Jeff
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){
//load the dataset with the xml file
ds = new DataSet();

//load string with full path to xml file
string strFile = Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml"; //load the dataset with the xml file
ds.ReadXml (strFile, XmlReadMode.InferSchema);

string strDate = ((TextBox)(e.Item.Cells[2].Controls [0])).Text; string strException = ((TextBox)(e.Item.Cells[3].Controls [0])).Text; string strDuration = ((TextBox)(e.Item.Cells[4].Controls [0])).Text;
//get current row
DataRow dr = ds.Tables["exceptions"].Rows [e.Item.ItemIndex]; dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.Tables["exceptions"].AcceptChanges();
ds.WriteXml (Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml"); DataGrid1.EditItemIndex = -1;
BindDataGrid();
}

Nov 17 '05 #2

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

Similar topics

11
16068
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
0
1285
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
1
5273
by: sandman | last post by:
I've got a simple windows form with some bound textboxes and Save button. Each texbox is bound to column in a table in an Access database. The form fills fine - all the fields show the correct...
4
10959
by: Angel | last post by:
How can I update the datatable with the datagrid values after the datagrid itself has been modified.? I assume it's not automatically done. Thanks.
6
9845
by: mkobus | last post by:
Im relatively new, so please be patient with me... I need to update a parent .aspx screen from a popup and close the popup. Normally I would use...
9
4587
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...
5
2011
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
1
1521
by: jason | last post by:
The guts of the below asp.net vb code was pieced together from another thread - all due credit to it's original author. Thank you! I've modified it to maintain a small local Microsoft 2000...
8
1532
by: Scott Meddows | last post by:
I have a datagrid control that I've inherited from the base datagrid control (Source below). I am applying a datatable style onto the datatable that I assign as my datasource. All of my column...
0
6964
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
7175
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...
1
6842
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
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
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,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.