这看起来很琐碎,我以前知道如何在同一时间做到这一点,但由于某种原因,我似乎无法让我的头围绕这个时候:下拉列表中选择值
我有两个表: Hotel
和HotelRooms
Hotel
表有HotelID
和其他酒店的详细信息和HotelID
被发现在HotelRooms
与不同的房型,每个房型有一个描述。 一家酒店可以有许多房型。
我有一个DropDownList
,其中包含HotelID
和RoomIDs
。 HotelID
来自会话变量。 HotelID
是为DropDownList; but the list displays
RoomType值. When
Roomtypes are selected I want to display a
GridView`与酒店房间的细节,如描述,价格等....
我不能这样做,因为我的DropDownList的值是HotelID
被映射到Session ID
。如何从DropDownList的选定值中获取酒店客房的详细信息?
更新:
代码的GridView:
string intResortID = Request.QueryString("intResortID ")
string strRoomType = DropDownList2.SelectedValue;
string connStr = ConfigurationManager.ConnectionStrings["bdsConnectionString"].ConnectionString;
SqlConnection Con = new SqlConnection(connStr);
SqlDataAdapter sdr = new SqlDataAdapter("SELECT TOP (100) PERCENT tblAvail.dtm, tblResortsRooms.strRoomType, tblResortsRooms.strDescription, tblAvail.intQty, tblAvail.curPrice, tblAvail.intResortID, tblResortsRooms.intWSCode FROM tblAvailable INNER JOIN tblResortsRooms ON tblAvail.intResortID = tblResortsRooms.intResortID AND tblAvail.strRoomType = tblResortsRooms.strRoomType WHERE (tblResortsRooms.curRecRate > 0) AND (tblAvail.intResortID = @intResortID) AND (tblAvail.strRoomType = @strRoomType) AND (tblAvailable.dtm >= { fn CURDATE() }) ORDER BY tblResortsRooms.strRoomType",Con);
SqlParameter ResID = new SqlParameter("@intResortID", intResortID);
SqlParameter RoomType = new SqlParameter("@strRoomType", strRoomType);
sdr.SelectCommand.Parameters.Add(ResID);
sdr.SelectCommand.Parameters.Add(RoomType);
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="SqlDataSource2" DataTextField="strRoomType"
DataValueField="intResortID"
onselectedindexchanged="DropDownList2_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
SelectCommand="SELECT [intResortID], [strRoomType] FROM [tblResortsRooms] WHERE ([intResortID] = @intResortID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="intResortID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
可你至少告诉我们一些代码? ^^ – Thousand
以上更新的问题 – user1270384
您在哪里以及如何填写您的下拉列表?你能证明吗? – Thousand