Wednesday

Connecting DetailsView and GridView

The method of using a separate data source control that can be used by any server control that can feed on external data is very productive. Like XML allows the separation of content from the the presentation and client-side manipulation - such separation allows for painless change of data sources to different tables, databases, file systems without changing the way your site looks and functions.

For more user convenience you might want to create a relationship between the GridView and DetailView so that DteailsView shows the record that has been selected in the GridView. For any operations using SqlDataSource differently in different controls you need to create another SqlDataSource2 by dropping it on the design view. Then configure the second SqlDataSource2 for the same table but using WHERE clause and choosing Column = "key field of the table" (for example "id"), Operator will be "=", Source = "control", and control (that delivers the value for key) will be GridView1 (or whatever control you are synchronizing the DetailsView with).