xsd.exe Typed DataSet generation

M

Matthew Baskey

Hello,

I am loading a DataSet from an xml file and binding it to a
hierarchical datagrid. I am trying to write some keys between the
elements in my xml file into the xsd file. When I write the keys as
elements it works and I get the

public QuestionRow FindByorder(short order) {
return ((MenuTitlesRow)(this.Rows.Find(new object[] {order})));
}

however when I change these to attributes I loose my this method when
running
xsd.exe test.xsd /d

I need my xml to be structured with attributes, is there anyway I can
do this without have to transform the final output.

There is curiously very little literature available on the web about
this and what is very basic.

Here is my xsd file....

<?xml version="1.0" standalone="yes"?>
<xs:schema id="Test" targetNamespace="http://tempuri.org/test.xsd"
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://tempuri.org/test.xsd"
xmlns:mstns="http://tempuri.org/test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Test" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Question">
<xs:complexType>
<xs:sequence>
<xs:element name="Option" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="parent" type="xs:short" />
<xs:attribute name="suborder" type="xs:short" />
<xs:attribute name="Text" type="xs:string" />
<xs:attribute name="Selected" type="xs:string" />
<xs:attribute name="Tooltip" type="xs:string" />
<xs:attribute name="Answer" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:short" use="required" />
<xs:attribute name="Text" type="xs:string" use="required"
/>
<xs:attribute name="Type" type="xs:string" use="required"
/>
<xs:attribute name="Score" type="xs:string" use="required"
/>
<xs:attribute name="Mandatory" type="xs:string"
use="required" />
<xs:attribute name="Tooltip" type="xs:string"
use="required" />
<xs:attribute name="MultiSelect" type="xs:string"
use="optional" />
<xs:attribute name="AllowNoSelection" type="xs:string"
use="optional" />
<xs:attribute name="Multiline" type="xs:string"
use="optional"/>
<xs:attribute name="MaxLength" type="xs:string"
use="optional" />
<xs:attribute name="MinLength" type="xs:string"
use="optional" />
<xs:attribute name="InitialValue" type="xs:string"
use="optional" />
<xs:attribute name="Validation" type="xs:string"
use="optional" />
<xs:attribute name="Answer" type="xs:string"
use="optional" />
</xs:complexType>
<xs:key name="QuestionKey2" msdata:primaryKey="true">
<xs:selector xpath=".//mstns:Question" />
<xs:field xpath="mstns:id" />
</xs:key>
<xs:keyref name="QuestionOption" refer="QuestionKey2"
msdata:AcceptRejectRule="Cascade" msdata:DeleteRule="Cascade"
msdata:UpdateRule="Cascade">
<xs:selector xpath=".//mstns:Option" />
<xs:field xpath="mstns:parent" />
</xs:keyref>
<xs:key name="QuestionKey1" msdata:primaryKey="true">
<xs:selector xpath=".//mstns:Option" />
<xs:field xpath="mstns:parent" />
<xs:field xpath="mstns:suborder" />
</xs:key>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

I am trying to the following in the Update_click method of the
datagrid....


Test dst = (Test)Session("Test");
short order = Convert.ToInt16(HierarGrid1.DataKeys[e.Item.ItemIndex]);
Test.QuestionRow row =
(Test.QuestionRow)dst.Question.FindByorder(order);

also it appears DataKeys are empty...


Thanks for any light shed on this area,
Matt
 
S

Sean S.

You may need to fire the .AcceptChanges() function, otherwise the keys
that were changed are marked as changed values.
 

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top