Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 7th, 2009, 10:10 PM
Authorized User
Join Date: Jun 2003
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help With Better Databinding

I get an array of Document objects from a web service call. Each Document object has an array of Property objects. Each Property object has two properties, Name and Value. Such as

<Property Name="Title" Value="Test Title">
<Property Name="Category" Value="Test Subject">

My question is this, what is the best method for changing this array of Document objects into a bindable data source for a datagrid. In the past I've done the following, serialize the object to xml and run an xsl transformation on it to make the below xml and then read that xml into a datatable. I'm looking for a better way to make the Documents array bindable. Can I get some suggestions please?

<Title>Test Title</Title>
<Category>Test Subject</Category>

Last edited by AgentSmith; March 7th, 2009 at 10:11 PM.. Reason: Formatting
  #2 (permalink)  
Old March 8th, 2009, 04:05 PM
Friend of Wrox
Join Date: Dec 2008
Location: , , .
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts

Assume xml is a String that contains the xml document:
GridView1.DataSource = from p in XDocument.Parse(xml).Elements("Docs").Elements("Doc") select new { Title = p.Elements().ElementAt(0).Attribute("Value").Value, Category = p.Elements().ElementAt(1).Attribute("Value").Value };

Similar Threads
Thread Thread Starter Forum Replies Last Post
databinding getdates moneymk109 ASP.NET 2.0 Basics 0 April 8th, 2006 12:56 AM
databinding in VB2005 Bhuvana ADO.NET 0 March 9th, 2006 02:14 AM
Databinding with an inner join Louisa VB.NET 2002/2003 Basics 2 December 12th, 2003 04:57 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.