I am trying to understand typed datasets more.... and i am stuck on a little
problem
I have created a type dataset called "News" this consists of 2 tables.
NewsTable and NewsTypes.
the news has news_id int, title string and type int
the news type table has type_id int and type_name string
There is also a relationship created which is joining on the news.type and
then newstype.type_id
In the code below i am putting in 2 rows for types... and 1 row for a news
article. Then further is the xsd file.
My question is .... how can i get the STRING value of the newstype that
relates to my news item? eg i want an easy way to get to the value "first
type"
Any help would me much appreciated.
News myNews = new News();
News.NewsTypesRow tRow;
// Add some types
tRow = myNews.NewsTypes.NewNewsTypesRow();
tRow.type_id = 1;
tRow.type_name = "first type";
tRow.type_id = 2;
tRow.type_name = "second type";
// Add some datat to the news
News.NewsTableRow nRow = myNews.NewsTable.NewNewsTableRow();
nRow.title = "news title";
nRow.type = 1;
MessageBox.Show(nRow.title.ToString());
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="News" targetNamespace="http://tempuri.org/News.xsd"
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://tempuri.org/News.xsd"
xmlns:mstns="http://tempuri.org/News.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="News" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="NewsTable">
<xs:complexType>
<xs:sequence>
<xs:element name="news_id" type="xs:int" minOccurs="0" />
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="type" type="xs:int" minOccurs="0" />
<xs:element minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewsTypes">
<xs:complexType>
<xs:sequence>
<xs:element name="type_id" type="xs:int" minOccurs="0" />
<xs:element name="type_name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="TypeKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:NewsTypes" />
<xs:field xpath="mstns:type_id" />
</xs:key>
<xs:keyref name="NewsTypesNewsTable" refer="TypeKey">
<xs:selector xpath=".//mstns:NewsTable" />
<xs:field xpath="mstns:type" />
</xs:keyref>
</xs:element>
</xs:schema>