Karl Napp wrote:
> I have two tables:
> The first is "house" with the columns "house_id" and "house_name".
> The second is "room" with "house_id", "room_id", "room_name".
>
> Now, I have two DataGrids. The first should only show the
> "house_name" and OnClick it should be able to send the "house_id" to
> a method that will fill the second DataGrid.
>
> I have tried <asp:buttoncolumn datatextfield="house_name"> to show
> the name but I am not able to retrieve the id to send it to my method
>
Set DataKeyField="house_id" for the first datagrid.
Set the CommandName="Select" for your buttoncolumn.
In the OnSelectedIndexChanged event of the first datagrid
(NOT the OnClick event of the button), use this expression to
retrieve the house_id:
selectedHouseID = DataGrid1.DataKeys(e.Item.ItemIndex)
With this ID, bind your second datagrid.
You can also find a complete template in Web Matrix (use the Master/Detail
Data template).
--
Jos