473,614 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ 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_Updat eCommand(object source, System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
//load the dataset with the xml file
ds = new DataSet();

//load string with full path to xml file
string strFile = Server.MapPath( Request.Applica tionPath) + "\\exceptions.x ml";
//load the dataset with the xml file
ds.ReadXml (strFile, XmlReadMode.Inf erSchema);

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

//get current row
DataRow dr = ds.Tables["exceptions "].Rows[e.Item.ItemInde x];
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.Tables["exceptions "].AcceptChanges( );
ds.WriteXml (Server.MapPath (Request.Applic ationPath) + "\\exceptions.x ml");
DataGrid1.EditI temIndex = -1;
BindDataGrid();
}
Nov 17 '05 #1
1 1271
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_Updat eCommand(object source, System.Web.UI.W ebControls.Data GridCommandEven tArgs e){
//load the dataset with the xml file
ds = new DataSet();

//load string with full path to xml file
string strFile = Server.MapPath( Request.Applica tionPath) + "\\exceptions.x ml"; //load the dataset with the xml file
ds.ReadXml (strFile, XmlReadMode.Inf erSchema);

string strDate = ((TextBox)(e.It em.Cells[2].Controls [0])).Text; string strException = ((TextBox)(e.It em.Cells[3].Controls [0])).Text; string strDuration = ((TextBox)(e.It em.Cells[4].Controls [0])).Text;
//get current row
DataRow dr = ds.Tables["exceptions "].Rows [e.Item.ItemInde x]; dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.Tables["exceptions "].AcceptChanges( );
ds.WriteXml (Server.MapPath (Request.Applic ationPath) + "\\exceptions.x ml"); DataGrid1.EditI temIndex = -1;
BindDataGrid();
}

Nov 17 '05 #2

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

Similar topics

11
16143
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? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
0
1298
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 the database? I've used the following code for the DataGird1_UpdateCommand Option1
1
5283
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 data for the record I load. So then I change the contents of one of the textboxes and click on the Save button. The button's event handler then calls the data adapter's Update method and I check the return value. Nada-zilch-nothing. I even put a...
4
10969
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
9850
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 'window.opener.location.reload(true);self.close();' but i need the parent window not to reload or else data that the user has already entered will be lost during the IsPostBack. I need the 'Apply' button on the popup to trigger the 'Update' button on the parent screen. The script ive seen...
9
4599
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 consistant. Thanks, Tom.
5
2024
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 one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
1
1532
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 access DB via a datagrid control. The add and delete functions work great, but the edit does not actually update the database. I put in some displays and apparently on the first item in the grid gets set during editing, all others come back empty???
8
1543
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 but one are set as readonly=true. The writeable column does not update when I'm editing it. Is there something different that I need to be doing to update this data? Also, how do I get the "new row" to not appear at the bottom of the datagrid?...
0
8130
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8576
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8275
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8429
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5538
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4050
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4121
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2566
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 we have to send another system
0
1423
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.