473,765 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid support for XML with different node types

Hello,

I have xml like this....

<test>
<question>sdfsa </question>
<section><quest ion>43ga</question>
<question>asd f</question>
</test>

I make and xsd file with
<xs:all>
<xs:element.. ..
<xs:element.. ..
</xs:all>

I then bind the XML to a DataGrid...

DataGrid.DataSo urce = DataSet;
DataGrid.DataBi nd();

but I only get the questions, I notice there is a DataMember property
I can set to DataGrid.DataMe mber = "Section"; and I will get that one,
but essential I want a table with both elements in there...

Is there anyway to do this...?

Thank You
Nov 12 '05 #1
2 3269
Hi Magister

Try creating a DataSet in Visual Studio .NET using the design time
environment - you will see that if you create an element, then add a couple
of 'fields' to it, then the structure you get in the xsd looks a bit like
this:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Test" targetNamespace ="http://tempuri.org/Test.xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d" xmlns="http://tempuri.org/Test.xsd"
xmlns:mstns="ht tp://tempuri.org/Test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="Test" msdata:IsDataSe t="true">
<xs:complexType >
<xs:all>
<xs:element name="Test">
<xs:complexType >
<xs:sequence>
<xs:element name="Question" type="xs:string " minOccurs="0" />
<xs:element name="Answer" type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

Then you can bind to the Question and Answer 'columns' by setting the
DataSource. Essentially the XML data needs to look more table like to work
the way that you want, with a root element representing the table, top level
element children of the root representing rows, and grand children of the
root representing columns.

HTH

Nigel

"magister" wrote:
Hello,

I have xml like this....

<test>
<question>sdfsa </question>
<section><quest ion>43ga</question>
<question>asd f</question>
</test>

I make and xsd file with
<xs:all>
<xs:element.. ..
<xs:element.. ..
</xs:all>

I then bind the XML to a DataGrid...

DataGrid.DataSo urce = DataSet;
DataGrid.DataBi nd();

but I only get the questions, I notice there is a DataMember property
I can set to DataGrid.DataMe mber = "Section"; and I will get that one,
but essential I want a table with both elements in there...

Is there anyway to do this...?

Thank You

Nov 12 '05 #2
Thanks for getting back to me, the thing is that I am binding to a
hierarchical grid control....I am using attributes as columns...

<test>
<question Type="Selection " Text="What is the capital of the USA">
<option Text="Texas" />
<option Text="DC" />
</question>
<section Type="Random" Text="Here is a section about France" >
<question Type="Selection " Text="What is the capital of the
France">
<option Text="Paris" />
<option Text="Lyon" />
</question>
<question Type="Input" Text="Type in the major language spoken in
France">
</section>
<question Type="Input" Text="Type in the major language spoken in
the USA">
<question Type="Selection " Text="What is the capital of the UK">>
<option Text="London" />
<option Text="Mancheste r" />
</question>
</test>

I wanteded to bind the columns of question and section in the first
level of the hierarchical grid as they have similar attribute columns,
but when I get my typed Dataset Section and Question are 2 different
tables...how can I put them together so they are one...?

Thanks,
Matt

Nigel Armstrong <Nigel Ar*******@discu ssions.microsof t.com> wrote in message news:<70******* *************** ************@mi crosoft.com>...
Hi Magister

Try creating a DataSet in Visual Studio .NET using the design time
environment - you will see that if you create an element, then add a couple
of 'fields' to it, then the structure you get in the xsd looks a bit like
this:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Test" targetNamespace ="http://tempuri.org/Test.xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d" xmlns="http://tempuri.org/Test.xsd"
xmlns:mstns="ht tp://tempuri.org/Test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="Test" msdata:IsDataSe t="true">
<xs:complexType >
<xs:all>
<xs:element name="Test">
<xs:complexType >
<xs:sequence>
<xs:element name="Question" type="xs:string " minOccurs="0" />
<xs:element name="Answer" type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>

Then you can bind to the Question and Answer 'columns' by setting the
DataSource. Essentially the XML data needs to look more table like to work
the way that you want, with a root element representing the table, top level
element children of the root representing rows, and grand children of the
root representing columns.

HTH

Nigel

"magister" wrote:
Hello,

I have xml like this....

<test>
<question>sdfsa </question>
<section><quest ion>43ga</question>
<question>asd f</question>
</test>

I make and xsd file with
<xs:all>
<xs:element.. ..
<xs:element.. ..
</xs:all>

I then bind the XML to a DataGrid...

DataGrid.DataSo urce = DataSet;
DataGrid.DataBi nd();

but I only get the questions, I notice there is a DataMember property
I can set to DataGrid.DataMe mber = "Section"; and I will get that one,
but essential I want a table with both elements in there...

Is there anyway to do this...?

Thank You

Nov 12 '05 #3

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

Similar topics

0
3189
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some text. Before changing to another cell in the DataGrid, I move my mouse pointer off the DataGrid and change the selected item in a ListBox or TreeView. Here's my question Which should fire first, the DataTable's RowChanged/CellChanged event or...
1
3729
by: Torre Quinn | last post by:
Does anyone have any good sites or resources dealing with adding drag and drop functionality to a set of controls on a form? I'd like to try to get several examples of varied applications of drag and drop being used on different types of controls. My current task is this. I have a treeview control and a data grid control. The data grid has two fields, 'value' and 'name'. I want to be able to drag nodes from the tree view and drop them...
2
2675
by: Carolyn Vo | last post by:
I have been looking and looking but can't seem to find out how to get the row selected in a web control datagrid (NOT a web form datagrid!!!), and how to highlight the selected row. I'm sure this question comes up all the time but I can't find the solution(s) anywhere. From what I understand, the web control datagrid doesn't have any row selected or row highlighting capabilities. What kind of hack am I going to have to put into place?...
1
1517
by: Michael Gorbach | last post by:
Iv got a StatisticsContainer object that contains an arraylist of objects of different types, all inherited from class Statistic. The statistics class has 2 string public properties, name and stringValue. The classes that inherit from it use those two properties, plus several properties of their own of types double and vector. I need to display this StatisticsContainer class on a datagrid, but I'm having problems because each of the...
3
1220
by: Raghuvansh | last post by:
I am databinding a grid to an XML source (given below). I am displaying the grid contents inside an TemplateColumn/ItemTemplate using regular <%# DataBinder.Eval(Container.DataItem, "Net-Change-Price") %> tags. My question is: How can I access/display the attributes of an XML node. More specifically in the current example, how can I access/display 'symbol' attribute in the 'equity-quote' node?
4
2011
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet, when the datagrid enters it's own OnPreRender, the selected index has reverted to zero. I created a debug version of the dropdown list which inherited from dropdownlist and overrode the selected index property to trace.write whenever it was...
5
2231
by: lanem | last post by:
I want to display some drill-down data with a datagrid look. I can get the exact functionality I want with a treeview, but I don't like the way the treeview looks and formats the data. I want a multi-column table look like a datagrid. It is not as easy as just hardcoding a datagrid within a datagrid because the data may do down pretty deep. The treeview works great for this. Is there a way to make the treeview look kind of like a...
3
1081
by: Rodi Roberto | last post by:
Hi all, i have a problem on a datagrid (webforms), i don't know if is a problem on my code, if is a bug of DataGrid or simply if is normal... When i add a node on a datagrid or when i delete a node, all works fine, but at this moment if you press F5 to refresh the page, my application continue to add node(if i added a node) or to delete a node (if i deleted a node). What's happens? Thank you all , and scuse me for my bas english.
2
2603
by: Blacky | last post by:
Hi, I am using c# asp.net application.I have datagrid which binds column dynamically and i make certain columns say visibility to false in my itemdatabound event EMPID AS E.ITEM.CELLS.VISIBLE = FALSE.Now i want to perform validations based on this value in cell using javascript... By clicking on one rows checkbox in datagrid, i need to color all other rows which has the same value in the hidden column EMP... IE cells.. function...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.