473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem with two gridviews and SelectedValue

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
1 1150
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Giulio Santorini | last post by:
Hi, I've got two drop down list controls. When I select a value from the first one I fill the second one. And when I select a value from the second one I would like to fill another control. But...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
0
by: Jim in Arizona | last post by:
I built a ticket system a while back but I never could get the queries quite right. My queries work as long as I don't use a date range. Here is the code I use for the query portion (the relevant...
4
by: ber.janssens | last post by:
Hi, In ASP.NET 2.0, I have a GridView with 2 CommandFields, how can I determine in the SelectedIndexChanged event which CommandField is clicked? <asp:GridView ID="gvOrderList" runat="server"...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
2
by: newsgroups.jd | last post by:
Thanks for any advice, help in advance... I have 3 dropdownlist that populate based on choice in the previous (nested essentially) Problem is when I hit the back button and make a change in...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
1
by: rtwPhoenix | last post by:
The problem. I have created an exam using the control wizard. Most answers are text answers I created the SQL db. Now when I try to read the data it always gives me cast error. I am new at this...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.