這看起來很瑣碎,我以前知道如何在同一時間做到這一點,但由於某種原因,我似乎無法讓我的頭圍繞這個時候:下拉列表中選擇值
我有兩個表: 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