Click to See Complete Forum and Search --> : XML from SQL into Gridview (Friendly names)


amean_n
04-19-2011, 10:43 AM
Hi there,

I have data in an SQL database and have managed to display it in Gridview using .net

The problem I need to overcome is to figure out how (Programatically) to display the xml data in friendly form.

For testing purposes I am using the XML node item name of Pres1 and another one called pres2.

I need the c# behind the aspx page to create an XML doc from the SQL database and then overide the existing grid cell (19) with the correct name.


Please note the XML document does not exist, the data is in a SQL database (Colomn "presentationData") with the connection string already in place.

Thanks

Ribeyed
04-22-2011, 09:29 AM
Hi,
Pasre the XML file into a string, use repace on the nodes you want to change then name parse back to xml and databind to your gridview should do the trick.

Here is example of parsing xml to string:

http://www.netomatix.com/XmlFileToString.aspx

Use:


string NewXMLString = XMLString.Replace("<OLDNODE>", "<NEWNODE>");


then create a XMLReader to read the contents of the XMLString:

http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx


regards


Ribs