I've seen several master-detail examples using a GridView that controls a DetailsView but no parent-child examples that reverse their roles (i.e., an example using a DetailsView that contains and controls a GridView). I alluded to such a scenario in a previous post. Here, I'll walk through the steps to create such a display.
- Create the database and tables. If you already have one with a parent-child (i.e., one-to-many) relationship, you can skip this step. Also, if you're using SQL Server 2005 instead of its Express edition, skip to sub-step c.
- From the Project menu, select "Add New Item…".
- Select the Data category, and then select the SQL Server Database template and click "Add". If it then prompts you to place it in the App_Data folder, click "Yes".

- Create a two tables, one of which has a foreign key into the other. Here is the example I'll use.

- Add some data to the tables. I'll add two companies with two divisions each.
- Create a new Web form or use one you already have. I'll use Default.aspx. Open it and switch to the Design view.
- Add a DetailsView to the design surface. You can find it in the Data section of the Toolbox.

- From the "Choose Data Source" drop-down list, select "<New data source…>". I'll select the Database data source for this walk-through.

- Select the connection to your database from the drop-down list. If it's not there, click "New Connection…" to create a new one.
- Click "Next" to save the connection string in Web.config.
- In the "Configure the Select Statement" step, select the "Companies" table (or whichever table is the parent in your schema) and select "*" to see all columns in the DetailsView. Click "Next".

- Test the query if you like. Click "Finish".
- Click the Smart Tag symbol on the DetailsView control to open it and select "Add New Field…".

- Select "TemplateField" from the "Choose a field type" drop-down list and enter some header text. I'll enter "Divisions" since that's the name of my child table. Click "OK".

- Select "Edit Templates" from Smart Tag. The control enters "Edit Template Mode" and displays an empty item template for the Divisions field. Drag a GridView from the Data section of the Toolbox into the item template.

- Create a new data source as above (steps 4 through 8) for the GridView but select all columns from the Companies table (or whichever table is the parent in your schema) instead. There is one issue to beware. VS will name the new data source for the GridView the same as that for the DetailsView. (I previously used the default, SqlDataSource1.) This will cause a designer error. Be sure to use a different name for the new data source. I'll use what is supposed to be the default, SqlDataSource2.
- If you run it now, you'll see one company but all divisions, not just those for that company.
- In the "Configure the Select Statement" page of the "Configure Data Source" wizard (the page where you select "*"), click the "WHERE…" button.
- In the "Add WHERE Clause" dialog, select "CompanyId" from the "Column" drop-down list and select "Control" from the "Source" drop-down list.
- In the Parameter properties section, select DetailsView1 from the Control ID drop-down list. Click "Add" and then click "OK".

- Verify the SELECT statement. Mine is "SELECT * FROM [Divisions] WHERE ([CompanyId] = @CompanyId)". Click "Next".
- Test the query if you like. Click "Finish".
- Press F5. Here's what it looks like in my browser.

I ran through the instructions of my previous post and had no problems with that combination of GridView, ObjectDataSource, DataSet, and stored procedures using Visual Studio 2008. It appears Microsoft fixed it since Orcas.