DataGrid binding question

G

Guest

Hi

I'm returning XML from a Web Service with the format of

<companylist><rowcount>55</rowcount><company><companyid>383823</companyid><companyname>ABC Corp.</companyname></company><company><companyid>383969</companyid><companyname>XYZ Inc.</companyname></company><company
etc..
</companylist

The columns in my datagrid are defined as

<Columns><asp:BoundColumn DataField="CompanyId" HeaderText="CompanyId" Visible="False"></asp:BoundColumn><asp:BoundColumn DataField="CompanyName" HeaderText="CompanyName" Visible="False"></asp:BoundColumn></Columns

When I keep the <rowcount> node in the XML I get

A field or property with the name 'CompanyName' was not found on the selected datasourc

When I remove <rowcount> from the XML altogether, the databinding works. Does the DataGrid only handle non-nested XML? Is there way for the datagrid to handle this or do I have to remove <rowcount> node using code before setting the datasource and calling the DataBind method

Dave.
 
M

Malek

What are you binding your grid to ? a DataSet ? an XmlDocument ?
Dave said:
Hi,

I'm returning XML from a Web Service with the format of:
<companylist><rowcount>55</rowcount><company><companyid>383823</companyid><c
ompanyname>ABC
Corp. said:
etc...
</companylist>

The columns in my datagrid are defined as:

<Columns><asp:BoundColumn DataField="CompanyId" HeaderText="CompanyId"
Visible="False"> said:
When I keep the <rowcount> node in the XML I get:

A field or property with the name 'CompanyName' was not found on the selected datasource

When I remove <rowcount> from the XML altogether, the databinding works.
Does the DataGrid only handle non-nested XML? Is there way for the datagrid
 
P

Prodip Saha

Dave,
The rowcount should not belong to companylist. Even though you can write xml
anyway you want it as long as they have paired tags but you would not be
able to parse them in a certain patern (<company></company> in this case).

Prodip

Dave said:
Hi,

I'm returning XML from a Web Service with the format of:
<companylist><rowcount>55</rowcount><company><companyid>383823</companyid><c
ompanyname>ABC
Corp. said:
etc...
</companylist>

The columns in my datagrid are defined as:

<Columns><asp:BoundColumn DataField="CompanyId" HeaderText="CompanyId"
Visible="False"> said:
When I keep the <rowcount> node in the XML I get:

A field or property with the name 'CompanyName' was not found on the selected datasource

When I remove <rowcount> from the XML altogether, the databinding works.
Does the DataGrid only handle non-nested XML? Is there way for the datagrid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top