Master / details grid

M

M@

Hy,
I would like to create a master /detail datagrid,
that is a datagrid that (when I click on an item)
shows some other item's details
expanding the rows under the selected grid

Can someone help me with this?

Thanks!

M@
 
D

Dave

M,
I have done this in a web application I wrote. As you probably know, the
datagrid web control does not inherently support master-detail datagrids.
What you need to do is:

1. Add a select button column to your datagrid (a simple google search
will give you simple instructions on this
2. Perhaps change the "selecteditem" style to bold or something to make
it stand out
3. Add the following to your html tag for the datagrid:
"Onselectedindexchanged = "datagrid1_SelectedIndexChanged" This will fire
an event when you hit the select button for a particular row in your
datagrid
4. Set your "DataKeyField" property on the datagrid to the table's field
value that links it to the detail datagrid (usually a primary key field i.e.
AuthorID)
5. Create a second datagrid (your detail datagrid)
6. In the datagrid1_SelectedIndexChanged Sub, set up and execute a
connection/command with a SQL statement that references the selectedindex of
the master datagrid in the WHERE clause of your SQL statement (i.e. SELECT
booktitles, ISBNNumber FROM tbl_Books WHERE AuthorID =
datagrid1.items.item(datagrid1.selecteditem.itemindex).Cells(0).Text
7. Bind your detail datagrid and refresh the page

That should get you started in the right direction.
 
M

M@

5. Create a second datagrid (your detail datagrid)

Ok, that's correct, but the effect I would like ti reproduce is different:
only one datagrid, when the user click on the item
the selected row expands itself and shows
some detailed information.

Have you ever seen some grid like this?

Thanks

M@
 

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

Top