R
Rick
Using VWD, I am attempting to create a basic Master/Detail scenario
from a SQL database table that has two primary keys. The Master
control I'm using is a GridView, containing a list of records from the
table in question, with Select enabled. The Detail control is another
GridView. Assume a valid connection string. Here's the control code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="pkfield1,pkfield2"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="pkfield1" HeaderText="pkfield1"
ReadOnly="True" SortExpression="pkfield1" />
<asp:BoundField DataField="field_name" HeaderText="field_name"
SortExpression="field_name" />
<asp:BoundField DataField="pkfield2" HeaderText="pkfield2"
ReadOnly="True" SortExpression="pkfield2" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ValidConnectionString %>"
SelectCommand="SELECT [pkfield1], [field_name], [pkfield2] FROM
[dbtable] WHERE ([pkfield1] = @pkfield1)">
<SelectParameters>
<asp
arameter DefaultValue="5" Name="pkfield1" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataKeyNames="pkfield1,pkfield2"
DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="pkfield1" HeaderText="pkfield1"
ReadOnly="True" SortExpression="pkfield1" />
<asp:BoundField DataField="pkfield2" HeaderText="pkfield2"
ReadOnly="True" SortExpression="pkfield2" />
<asp:BoundField DataField="field_symbol" HeaderText="field_symbol"
SortExpression="field_symbol" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ValidConnectionString %>"
SelectCommand="SELECT pkfield1, pkfield2, field_symbol FROM
[dbtable] WHERE (([pkfield1] = @pkfield1) AND ([pkfield2] =
@pkfield2))">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="pkfield1"
PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="GridView1" Name="pkfield2"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
Assuming that the database objects are all properly structured and the
rest of the code for the page is okay, is there any obvious reason why
the above control code wouldn't produce a visible, populated second
(Detail) GridView ? I have played with many different versions on this
theme, and found that if there's a single parameter being used in the
WHERE for the second data source, it works fine. But with two WHERE
parameters, at least as I did it above, it doesn't work -- nothing
shows up.
Can anyone offer me some assistance with this ? Thanks.
Rick
from a SQL database table that has two primary keys. The Master
control I'm using is a GridView, containing a list of records from the
table in question, with Select enabled. The Detail control is another
GridView. Assume a valid connection string. Here's the control code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="pkfield1,pkfield2"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="pkfield1" HeaderText="pkfield1"
ReadOnly="True" SortExpression="pkfield1" />
<asp:BoundField DataField="field_name" HeaderText="field_name"
SortExpression="field_name" />
<asp:BoundField DataField="pkfield2" HeaderText="pkfield2"
ReadOnly="True" SortExpression="pkfield2" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ValidConnectionString %>"
SelectCommand="SELECT [pkfield1], [field_name], [pkfield2] FROM
[dbtable] WHERE ([pkfield1] = @pkfield1)">
<SelectParameters>
<asp
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataKeyNames="pkfield1,pkfield2"
DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="pkfield1" HeaderText="pkfield1"
ReadOnly="True" SortExpression="pkfield1" />
<asp:BoundField DataField="pkfield2" HeaderText="pkfield2"
ReadOnly="True" SortExpression="pkfield2" />
<asp:BoundField DataField="field_symbol" HeaderText="field_symbol"
SortExpression="field_symbol" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ValidConnectionString %>"
SelectCommand="SELECT pkfield1, pkfield2, field_symbol FROM
[dbtable] WHERE (([pkfield1] = @pkfield1) AND ([pkfield2] =
@pkfield2))">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="pkfield1"
PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="GridView1" Name="pkfield2"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
Assuming that the database objects are all properly structured and the
rest of the code for the page is okay, is there any obvious reason why
the above control code wouldn't produce a visible, populated second
(Detail) GridView ? I have played with many different versions on this
theme, and found that if there's a single parameter being used in the
WHERE for the second data source, it works fine. But with two WHERE
parameters, at least as I did it above, it doesn't work -- nothing
shows up.
Can anyone offer me some assistance with this ? Thanks.
Rick