Datatables and relations?

  • Thread starter Thread starter Dianne Howard
  • Start date Start date
D

Dianne Howard

Hi all,

Please can anyone help with the following:
I want to display selected records retieved by a stored
procedure in a datagrid (using a template column) - sorted
by the category field, with relevant records displayed
underneath.

I can get as far as displaying all results, but the
problem I'm having is that I only want to display each
category once, e.g. If I have 10 records that belong to
category 'A', I don't want Category 'A' to appear 10 times
at the top of each result in the datagrid - only once.

I think that this involves using datatables/relationships
and/or views, but I don't have a clue how to do it.

Please help before I go insane!

Thanks
Dianne
 
Dianne:

If you have only ten records in ParentTable of which one record is A and you
have 20000 records in the child, 20 of which are A...and you use a
DataRelation and bind your controls, when you go to select Value A from the
parent, the grid should be restricted to only the child values that relate
to A.

How are you doing your DataRelations and Bindings?
 
Hi,

I haven't coded the data relations yet. At the moment all
the code is doing is filling a dataAdapter with the
records returned by the stored procedure. I've been
reading through some information on data relations and
data tables, but I'm just a bit confused!

Do I need to create 2 data tables - one containing the
parent details (i.e. the category), and one containing the
child details (i.e. all the records relating to that
category)?

Do I then need to create a relationship between these two
data tables?

Do I require two dataAdapters to do this?

What do I bind to the datagrid?

This is probably quite basic stuff, but I'm new to all of
this. It would be really useful if I could find a code
example.

Thanks for your help

Dianne
 
Hi Harsh,

thanks for your suggestion, that's what I tried first as I
thought that this would work but it doesn't seem to.

Thanks

Dianne
-----Original Message-----
Can you not use SELECT DISTINCT in your Stored Procedure?
Unless you intend to use the all the data, there is no
point in fetching it from the database.
 

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

Back
Top