asp.net c# - please help!

Soldato
Joined
12 Jan 2004
Posts
6,824
Location
Londinium
I have written a generic component to manage xml data files via a web interface using a datagrid. I have managed to read the selected xml file into the dataset, then populate a datagrid using that dataset. i have also sorted out the edit and cancel buttons for the datagrid, but i am stuck on update.

I want to be able to write the edited datagrid into the source xml file. The important point is that I do not know how many columns the xml may have. That means I need to loop through the ItemArray for that row to get the new values and put them in the data set in the right places. This is the bit i cant figure out!

This is what I have so far:

Code:
    protected void dgXmlContents_Update(Object objSource, DataGridCommandEventArgs e)
    {
        // Set datagrid to uneditable
        dgXmlContents.EditItemIndex = -1;
        
        // Get new dataset with original xml contents
        DataSet ds = GetXmlData();

        // overwrite ds with user made changes in the datagrid dgXmlContents

        // Write new data to xml file
        ds.WriteXml(Server.MapPath(Utility.GetXmlDir() + "temp.xml"));
        
        // Reload xml
        LoadXml();
    }

dgXmlContents_Update is called by clicking the update button on the datagrid (dgXmlContents) row. Can someone please complete the code to insert the new column values into the dataset?
 
Back
Top Bottom