Some of these steps should be pretty casual, others I am not sure because I
have not worked on GridView in a while.
Your first step "Populate a GridView from an xml file" could be a simple as
databinding the GridView control to an XmlDataSource control (if you are
using GridView you must be using a Whidbey, therefore the data source
controls are also available). You can do this programmatically in the code
behind if you have to (there are some limited samples on this somewhere), or
use VS.NET to do it declaratively on the ASPX page.
"Add Fields to the GridView".... you should be able to do this
programmatically, too, check out the samples for GridView in the docs. You
might have to add these fields specifically after a databound event signals
that the GridView is populated, but before render time..?
"Write contents of GridView to new xml file". I assume you mean on postback,
right? read below...
If writing the Gridview to a new xml file, and not persisting changes to the
file you loaded from is the real goal, you might go about this whole
scenario like a little differently. Maybe load a DataSet in memory from an
XML file. Add columns to the DataSet that represent the extra fields you
want the GridView to display, perhaps add fields to GridView pre-render?
Databind the GridView to the DataSet. Finally, on post-back, save the
DataSet and any of its changes to a new XML file. The DataSet might make the
transform to and from different XML files (and schemas, effectively, since
you are adding columns of data) a bit easier.
HTH, Alex
[quoted text, click to view] "theKirk" <theKirk@discussions.microsoft.com> wrote in message
news:F5525332-BACC-4606-A925-2570C20B86AA@microsoft.com...
> 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 GridView to allow entry of quantity and Y/N switch for
> each row
>
> Write contents of GridView to new xml file.
>
> Example...
>
> xml file that populates gridview cols:
>
> <items>
> <item id=1>
> <name="Bread" />
> <price="1.10" />
> </item>
> <item id=2>
> <name="Milk" />
> <price="2.20" />
> </item>
> <item id=3>
> <name="Cookies" />
> <price="3.30" />
> </item>
> </items>
>
> Grid View shows:
>
> Bread 1.10 (textboxQuantity = 3)
> Milk 2.20 (textboxQuantity = 6)
> Cookies 3.30 (textboxQuantity = 9)
>
>
> new xml file output should look like:
>
> <items>
> <item id=1 quantity=3 price=1.10 />
> <item id=2 quantity=6 price=2.20 />
> <item id=3 quantity=9 price=3.30 />
> </items>
>
>
> Thanks.
>
>