Summary: Query a child table using a column from a parent table. A simpler example of this would be if the column belongs to the same table. This topic uses two tables related by a parent-child relationship. The parent table contains the data key that is the foreign key in the child table. See the following picture.
A query is built based on the values assigned to the foreign key. The selection of the values for querying the data source is performed in a source data-bound control. The results of the query are shown in a target data-bound control.
The following picture shows the main elements involved during querying (filtering).
To query a table by a data key, you must perform the following steps:
<asp:GridView ID="SourceGridView" DataSourceID="GridDataSource" runat="server">
</asp:GridView>
<aspX:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true" ContextTypeName="DynamicDataProject.NorthwindDataContext" TableName="Categories"> </aspX:LinqDataSource>
<asp:GridView ID="TargetGridView" DataSourceID="DetailsDataSource" runat="server">
<aspX:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="true" EnableUpdate="true" ContextTypeName="DynamicDataProject.NorthwindDataContext" TableName="Products"> </aspX:LinqDataSource>
<aspX:QueryExtender TargetControlID="DetailsDataSource" runat="server"> <asp:ControlFilterExpression ControlD="SourceGridView" Column="Category" /> </aspX:QueryExtender>
<aspX:QueryExtender TargetControlID="DetailsDataSource" runat="server">
<asp:ControlFilterExpression ControlD="SourceGridView" Column="Category" />
</aspX:QueryExtender>
Note:
For a complete example, see the attached files.
PingBack from http://blog.a-foton.ru/index.php/2009/01/30/querying-dynamic-data-table-by-a-data-key/
Introduction What : Create your own project, called DynamicDataProject, that mimics the SampleProject