PC Review


Reply
Thread Tools Rate Thread

datagrid with nested dataset

 
 
suzy
Guest
Posts: n/a
 
      18th Jul 2003
im building a datagrid control at runtime using a dataset as the datasource
and everything was working fine.

i then needed to change my dataset to be nested data and now i don't know
how to set the DataField property of child values in the dataset.

can anyone help me please?!

thanks.


 
Reply With Quote
 
 
 
 
Kathleen Dollard
Guest
Posts: n/a
 
      19th Jul 2003
Suzy,

Unless someone else answers this, repost with a bit more information.
Specifically, what your DataSet looks like in terms of its tables and
relations.

The short answer is to set the tables and relations and bind to the DataSet,
letting the datagrid take care of the rest (assuming Windows.Forms)

--
Kathleen (MVP-VB)



"suzy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> im building a datagrid control at runtime using a dataset as the

datasource
> and everything was working fine.
>
> i then needed to change my dataset to be nested data and now i don't know
> how to set the DataField property of child values in the dataset.
>
> can anyone help me please?!
>
> thanks.
>
>



 
Reply With Quote
 
suzy
Guest
Posts: n/a
 
      19th Jul 2003
hi kath

my dataset contains 2 tables, customers and orders. one of the columns in
EACH table is called customerid which is a primary key in one table, and a
foreign key in the other table.

i create a dataset relation between these 2 fields, then set the
dataset.nested property to true to create a hierarchy.

my problem arises when i try to read the values from the dataset in order to
populate a datagrid. i can read the top level table by simply assigning the
name of the column to the datafield property of the datagrid.

but this doesn't work for the child table. i thought this would be a common
problem but i cant find the answer on the net. !!



"Kathleen Dollard" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Suzy,
>
> Unless someone else answers this, repost with a bit more information.
> Specifically, what your DataSet looks like in terms of its tables and
> relations.
>
> The short answer is to set the tables and relations and bind to the

DataSet,
> letting the datagrid take care of the rest (assuming Windows.Forms)
>
> --
> Kathleen (MVP-VB)
>
>
>
> "suzy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > im building a datagrid control at runtime using a dataset as the

> datasource
> > and everything was working fine.
> >
> > i then needed to change my dataset to be nested data and now i don't

know
> > how to set the DataField property of child values in the dataset.
> >
> > can anyone help me please?!
> >
> > thanks.
> >
> >

>
>



 
Reply With Quote
 
David Keenan
Guest
Posts: n/a
 
      20th Jul 2003
Suzy,
Do you need the DataGrid to display the data in nested
format or just the second table. If the latter then Bind
the DataGrid to your Orders table rather than directly to
the DataSet. ie

myDataGrid.DataSource = myDataSet.Tables["Orders"];

Hope this helps.

Dave

 
Reply With Quote
 
suzy
Guest
Posts: n/a
 
      20th Jul 2003
David,

i need to retrieve data from both tables, but the data does not need to be
displayed in a nested fashion.

for some reason i can read the values from the orders table, but it doesnt
work for the customers table (which is nested).

any ideas?


"David Keenan" <(E-Mail Removed)> wrote in message
news:041001c34eb7$aa75bb90$(E-Mail Removed)...
> Suzy,
> Do you need the DataGrid to display the data in nested
> format or just the second table. If the latter then Bind
> the DataGrid to your Orders table rather than directly to
> the DataSet. ie
>
> myDataGrid.DataSource = myDataSet.Tables["Orders"];
>
> Hope this helps.
>
> Dave
>



 
Reply With Quote
 
David Keenan
Guest
Posts: n/a
 
      20th Jul 2003
Suzy,

Are you sure that both Tables have been filled? Try
DataSet.Tables.Count to check that both Tables are
present. Then check that both Tables have data in them
using
DataSet.Tables[0].Rows.Count and
DataSet.Tables[1].Rows.Count

Providing that both Tables have data then you should be
able to display them by binding your DataGrid directly to
the Tables one at a time rather than to the DataSet by
setting the DataGrids DataSource to the Table.

i.e. if you have a DataGrid called myGrid and a DataSet
called myDS then do:

myGrid.DataSource = myDS.Tables[0];

to display the first Table and then use

myGrid.DataSource = myDS.Tables[1];

to display the second Table.

Hope this helps, if you still have problems then try
posting some code.

Regards,

Dave
 
Reply With Quote
 
David Keenan
Guest
Posts: n/a
 
      22nd Jul 2003
Suzy,

I'm not in the office this week so can't check your
code. One thing to try would be to replace

oDatagrid.DataSource = oDataSet;

with

oDatagrid.DataSource = oDataSet.Tables[1];

when you try to bind to your customer data.

If you're still having problems I'll have a look when I
get home.

Dave
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nested query and dataset nannu Microsoft C# .NET 3 7th Apr 2008 12:00 PM
problem in nesting datagrid in to a nested datagrid sajvargs Microsoft ASP .NET 0 20th Feb 2005 12:17 AM
How can I merge an untyped nested dataset to a typed nested dataset? Jim Hunt Microsoft ADO .NET 0 5th Oct 2004 05:13 PM
DataGrid Component | Displaying columns of a DataSet as Rows in a DataGrid ? Diego TERCERO Microsoft C# .NET 3 19th Dec 2003 02:21 PM
datagrid with nested dataset suzy Microsoft C# .NET 2 19th Jul 2003 10:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:04 AM.