Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7995225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:20:48+00:00 2026-06-04T14:20:48+00:00

This may seem very trivial, I used to know how to do this at

  • 0

This may seem very trivial, I used to know how to do this at one time but for some reason I can’t seem to get my head around it this time:

I have two tables: Hotel and HotelRooms
The Hotel table has HotelID and other hotel details and the HotelID is found in HotelRooms with different roomtypes, each roomtype has a description.
One Hotel can have many rooms types.

I have a DropDownList that contains HotelID and RoomIDs. HotelID comes from a session variable. HotelID is the value for the DropDownList; but the list displaysRoomType.
When
Roomtypesare selected I want to display aGridView` with the hotel room details like description, price etc….

I can’t do this because the value for my DropDownList is HotelID which is mapped to the Session ID. How do I get the HotelRoom details from the selected value of the DropDownList, please?

Update:

Code for 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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:20:50+00:00Added an answer on June 4, 2026 at 2:20 pm

    ‘DropDownList1.SelectedValue’ should give you the value for @intResortID.
    ‘DropDownList2.SelectedValue’ should give you the value for @strRoomType.

    DropDownList2_SelectedIndexChanged should run the query by filling something (like a DataTable).
    The filled DataTable should be bound to your GridView.

    Try something like the following in your DropDownList2_SelectedIndexChanged method:

    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);
    DataTable results = new DataTable();
    
    sdr.Fill(results);
    
    resultsGridView.DataSource = results;   //Assuming resultsGridView is the name of the GridView on your ASPX page.
    resultsGridView.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a very dumb question but I can't seem to get it
This may be something very easy but i can't seem to get this to
this may seem like a very simple question, but I want to dump some
This may seem like a very basic question, but its been in my head
This may seem to be an academic question, but still I would be very
This may seem a bit crazy, but if you can tell me a better
This may seem like a no-brainier, but the thing is I wont know the
This may seem stupid, but I can't see the events list on the Debug
I am still learning SQL so this may seem a very odd question, but
This may seem like a very simple question, but I have been struggling with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.