.net - Bind xml column and regular columns from sql server in nested controls -
I have a stored procedure that gives a mixture of plain columns and a 'column' of XML datatype. As:
Select field 1, field 2, ('Certification as selection certification', XML path for dbo.MemberCertificate from '@lcid' as LCID ('Certification'), type, root ('certificate')) with AS certificates .......
I am compelling this result in Gridview, and I have nested The XML column is required to be bound for Repeater, it contains parental-child data.
I have tried to set the repeater data source in the column name, such as:
" & Gt; & Lt; ItemTemplate & gt; & Lt;% # XPath ("// authentication")%> & Lt; / ItemTemplate & gt; & Lt; / ASP: Repeater & gt;
But it does not work, it seems as if it's coming in the form of a plain string, if I just write a line break inside the item template, then each letter in the column There is a break!
I have also tried to use an XML data inline, but I get a parser error:
I am at the end of my rope here - I am at that point where I am going to prepare my code by DSRaille XML.
Any thoughts?
Can you use LINQ in XML? You can load it in some way:
XDocument document = XDocument.Load (".. xml content here .."); Rpt.DataSource = document.Root.Elements ("Authentication"). (I => New {field1 = i.Element ("Field 1"). Value, Field 2 = i.Element ("field2") value}); Rpt.DataBind ();
Actually what I'm doing is converting the XML document into an anonymous type, which the repeater can reflect I'm sure some syntax is a bit far away (do not remember) That this value is property or something else, my Linux is a little messy for XML :-)) but basically how it can be done with this code. / P>
Inline markup I do not know if any method works after coming from the database. XmlDataSource requires a file and does not exceed the database (at least I know it may be wrong)
HTH
Comments
Post a Comment