By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

problem with two gridviews and SelectedValue

P: n/a
Hi,

In each classroom there are computers.
i have a gridview which shows all classrooms (from table location.
i have a second gridview which should show all computers of the selected row
in gridview1 (from table pc).

Gridview1 is not a problem, but when clicking on any Select of gridview1,
gridview2 doesn't appear.
When i replace in the code below this:
SelectCommand="SELECT * FROM [pc] WHERE ([lokl] = @lok
by this:
SelectCommand="SELECT * FROM [pc] WHERE ([lokl] = '3-35'
it works (3-35 is an existing classroom number).

The two tables have a common field (lok).

Thanks for help
Bart

Here the code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:les4demotestConnectionString1 %>"
SelectCommand="SELECT * FROM [location]"></asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" DataKeyNames="loknr"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="loknr" HeaderText="loknr"
InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="lok" HeaderText="lok" />
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:les4demotestConnectionString1 %>"
SelectCommand="SELECT * FROM [pc] WHERE ([lokl] = @lok)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="lok"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView ID="GridView2" runat="server" DataKeyNames="pcnr"
DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="pcnr" HeaderText="pcnr"
InsertVisible="False" ReadOnly="True"/>
<asp:BoundField DataField="name" HeaderText="name"
SortExpression="name" />
<asp:BoundField DataField="lok" HeaderText="lok"
SortExpression="lok" />
</Columns>
</asp:GridView>
Jun 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
i found it ..

"Bart" <b@sschreef in bericht
news:eD**************@TK2MSFTNGP02.phx.gbl...
Hi,

In each classroom there are computers.
i have a gridview which shows all classrooms (from table location.
i have a second gridview which should show all computers of the selected
row in gridview1 (from table pc).

Gridview1 is not a problem, but when clicking on any Select of gridview1,
gridview2 doesn't appear.
When i replace in the code below this:
SelectCommand="SELECT * FROM [pc] WHERE ([lokl] = @lok
by this:
SelectCommand="SELECT * FROM [pc] WHERE ([lokl] = '3-35'
it works (3-35 is an existing classroom number).

The two tables have a common field (lok).

Thanks for help
Bart

Here the code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:les4demotestConnectionString1 %>"
SelectCommand="SELECT * FROM [location]"></asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" DataKeyNames="loknr"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="loknr" HeaderText="loknr"
InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="lok" HeaderText="lok" />
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:les4demotestConnectionString1 %>"
SelectCommand="SELECT * FROM [pc] WHERE ([lokl] = @lok)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="lok"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView ID="GridView2" runat="server" DataKeyNames="pcnr"
DataSourceID="SqlDataSource2">
<Columns>
<asp:BoundField DataField="pcnr" HeaderText="pcnr"
InsertVisible="False" ReadOnly="True"/>
<asp:BoundField DataField="name" HeaderText="name"
SortExpression="name" />
<asp:BoundField DataField="lok" HeaderText="lok"
SortExpression="lok" />
</Columns>
</asp:GridView>

Jun 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.