0

I have an application that extracts data from some xml that is stored in a database. In the Page_Load event I have the code extracting the xml out of the db, parsing the XML and saving the data I need in a list of Strings. Then I use this code:

dataGrid.DataSource = from field in stringList select field;
dataGrid.DataBind();

It prints out the list, but I need to have more control over it. The GridView properties in the GUI don't really reflect anything from the Page_Load event (which I'm not too surprised about) but I need to be able to generate hyperlinks with the data and using an HTMLTextWriter didn't work as the GridView just auto-escaped all the HTML. I am not really a .Net programmer and am not familiar with how this works. Should I have put the custom code somewhere other that the Page_Load event?

1
  • can you tell more about your strings format? Commented Dec 13, 2009 at 23:16

2 Answers 2

2

http://msdn.microsoft.com/en-us/library/bb288031.aspx

you can use a template field and inside your item template, you would have a asp:hyperlink control. You would then use a <%#Bind(Container)%> in your asp:hyperlink) NavigateURL property)to bind

Sign up to request clarification or add additional context in comments.

Comments

0

Have you thought about using an XmlDataSource to bind the grid to your data?

You should be able to load the XML data into the datasource using something like this:

XmlDocument doc = xmlDataSource.GetXmlDocument();
doc.LoadXml(xmlFromTheDatabase);

2 Comments

the XmlDataSource seems to be for xml files...my xml is coming from a database column, and I can't save the xml to a file before using it, because of security considerations.
@Paul: See my updated answer for how to load the XML into the datasource without writing it to a file first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.