这可能看起来很微不足道,我曾经一次知道如何做到这一点,但由于某种原因,这次我似乎无法理解它:
我有两张桌子:桌子上有Hotel
和其他酒店详细信息,并且在不同HotelRooms
的房间类型中找到,每个房间类型都有描述。一间酒店可以有多种房型。Hotel
HotelID
HotelID
HotelRooms
我有一个DropDownList
包含HotelID
和RoomIDs
. HotelID
来自会话变量。HotelID
是 RoomType Roomtypes GridView` 的值,DropDownList; but the list displays
包含.
When
酒店are selected I want to display a
房间详细信息,如描述、价格等......
我不能这样做,因为我的 DropDownList 的值HotelID
是映射到Session ID
. 请问如何从 DropDownList 的选定值中获取 HotelRoom 详细信息?
更新:
网格视图的代码:
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>