Programatically binding dynamically generated Linq To Xml structure to GridView
-
I have an XDocument that I dynamically create from an external set of data. I would like to programatically bind the content of the whole document to a databound control such as a GridView. The caveat is that the XML structure will differ from one use to the next, so I cannot explicitly specify the structure of the resulting IEnumerable object. I need the structure to be implicitly generated based on the structure of the XML. At the moment the only way I've found of doing this is to import the XML into a DataSet and then bind that, but that somewhat misses the point. The XML can look something like this: bobsmith@acme.com List Type 1 Mr. Bob Smith Administration Manager Acme Inc bobsmith@acme.com List Type 2 Mr. Bob Smith Administration Manager Acme Inc bobsmith@acme.com List Type 3 Mr. Bob Smith Administration Manager Acme Inc
modified on Friday, June 6, 2008 4:39 AM
-
I have an XDocument that I dynamically create from an external set of data. I would like to programatically bind the content of the whole document to a databound control such as a GridView. The caveat is that the XML structure will differ from one use to the next, so I cannot explicitly specify the structure of the resulting IEnumerable object. I need the structure to be implicitly generated based on the structure of the XML. At the moment the only way I've found of doing this is to import the XML into a DataSet and then bind that, but that somewhat misses the point. The XML can look something like this: bobsmith@acme.com List Type 1 Mr. Bob Smith Administration Manager Acme Inc bobsmith@acme.com List Type 2 Mr. Bob Smith Administration Manager Acme Inc bobsmith@acme.com List Type 3 Mr. Bob Smith Administration Manager Acme Inc
modified on Friday, June 6, 2008 4:39 AM
Regarding binding to the content of the document, did you see the Bindable LINQ post right below this? I'm not sure if that works given your inability to "specify the structure of the enumerable". (Not quite sure what you mean by that, though, maybe you can clarify.)
Life, family, faith: Give me a visit. From my latest post: "How differently the psalmist saw it! How blessed -- how truly happy with real joy! -- is the man who delights in the Law of the Lord." Judah Himango