473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DataGrid binding question

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.
Nov 18 '05 #1
2 2420
What are you binding your grid to ? a DataSet ? an XmlDocument ?
"Dave" <an*******@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
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.</companyname></company><company><companyid>383969</companyid><companyn
ame>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 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
to handle this or do I have to remove <rowcount> node using code before
setting the datasource and calling the DataBind method?
Dave.

Nov 18 '05 #2
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" <an*******@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
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.</companyname></company><company><companyid>383969</companyid><companyn
ame>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 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
to handle this or do I have to remove <rowcount> node using code before
setting the datasource and calling the DataBind method?
Dave.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
2
by: VMI | last post by:
Hi, I have a Windows datagrid that's attached to a filled datatable. The grid also has a tablestyle. Since the data from the grid comes from a datatatable, how can I retrieve the data from a...
4
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
7
by: A.M | last post by:
Hi, I want to refresh my DataGrid data on every postback. I have following code in Page_Load event, but after first page load, the DataGrid never gets refresh. Here is the code i have in...
3
by: Pat | last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i populate the Child databrid using myDataGrid.SelectedIndex value as the filter and setting the DataKeyField. I enabled...
2
by: Brad Shook | last post by:
First of all thinks to Cor Ligthert for helping me with this last week. If you wild like to read Cor's comments please refer to the posting from 10/14/2004 and 8:48AM "Help with Advanced...
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.