How to interact between a ASP.gridview and ASP.detailview in a correct way?

How to interact between a ASP.gridview and ASP.detailview in a correct way?

Old forum URL: forums.lhotka.net/forums/t/1240.aspx


Frederick posted on Monday, September 18, 2006

I'm rather new to CSAL and I was just wondering how I would solve the following problem.

I have a asp.page with a datagrid and a detailsview. The datagrid is used to get an easy overview of all available cars. The detailsview is filled with the car info selected in te datagrid. The detailsview should support all editing options.

The setup until now:

A ReadOnlyListBase called CarList which is a list of CarInfo objects to fill the datag

The datasource for the detailsview is the Car object (BusinessBase). How do I fill the detailsview with the selected "car" from the datagrid? I have problems making the datagrid tell the detailsview its datasource that it has to change the object to load.

I was trying to trigger the detailsviewsource_select event from the datagrid_SelectedIndexChanged and then do something like this in the detailsview_onselect

if (gvCarList.SelectedDataKey != null)
{
//select correct car using the selected value from the datagrid
e.BusinessObject = fsp_admin.
Car.GetCar(Convert.ToInt32(gvCarList.SelectedDataKey.Value));
}

Edit : Found it. I just needed to call detailsview.databind() to trigger the detailsviewsource_select event.

Copyright (c) Marimer LLC