473,396 Members | 1,996 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.

Gridview - Writing grid changes from dataset to XML

I am having trouble updating a dataset representation of an xml file. The xml file is read into a dataset which is bound to a gridview control. The edit functionality was added to the code and handles the edit button fine. The data is changed on one of the fields in edit mode and captured in a variable when the update button is clicked. I attempt to assign the new value to the dataset's field in the edited datarow. I have seen examples of just that. The dataset is not updated and therefore when I do the ds.WriteXml it doesn't update the xml file.

The update method:
protected void dg1_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
// Get the new values from the GridView controls
int i = dg1.Rows[e.RowIndex].DataItemIndex;

TextBox txtName = dg1.Rows[e.RowIndex].Cells[2].FindControl("txtName") as TextBox;
string strName = txtName.Text;

dg1.EditIndex = -1;
Bind_Grid(dg1, dsMon, "dsMon", "monitor");

// Update the XML file using the new values
DataSet oDs = (DataSet)dg1.DataSource;
////Response.Write("Changed Data b4 = " + oDs.Tables[0].Rows[i].ItemArray[1]);
oDs.Tables[0].Rows[i].ItemArray[1] = strName;
////Response.Write("Changed Data after = " + oDs.Tables[0].Rows[i].ItemArray[1]);

String monitorsPath = Server.MapPath("App_Data/Monitors.xml");
oDs.WriteXml(Server.MapPath("App_Data/Monitors.xml"), XmlWriteMode.IgnoreSchema);
Cache["dsMon"] = oDs;

Bind_Grid(dg1, dsMon, "dsMon", "monitor");
}

What can I do to get that field updated with the edited txtName.Text from the grid?

Thanks for any and all help.
May 16 '07 #1
0 1089

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
2
by: rufpirat | last post by:
Hello I'm in the middle of trying to build an "AD phone book", and this being my first try at asp.net, I have a few questions that I hope some of you might be able to help with: 1. Is it...
1
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does...
7
by: GaryDean | last post by:
I'm trying to load a GridView up with data manually, in code. I'm not using any datasource. Using this code.... ArrayList myRowArrayList; GridViewRow myGVR = new...
12
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
0
by: Adam Sandler | last post by:
Hello, Prior to posting I looked at http://groups.google.com/group/ microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ d8d5ae243614085e/d4fd6c4a5aa56f75 ...
1
by: Orit | last post by:
Hi . I am creating an ASP.NET 2.0 web site and have the following problem : 1. I have a GridView which bound to the object data source. 2. This object data source is SQL Table adapter that I...
3
by: Joey | last post by:
asp.net 2.0 VS2005 C# In my web app I added a gridview and then manually configured boundcolumns, for an in-session dataset to act as a datasource. Then I added an Edit commandfield. When I...
5
by: brian | last post by:
I have a gridview that will contain 5000 + rows that is initially loaded into a dataset and bound to a gridview. On the form I have textboxes and dropdown list's I use to let the user fill in and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
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.