[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Populating DropDownlist in repeater based on value of other DropDownList in a repeater

Posted on 2013-06-18
3
Medium Priority
?
433 Views
Last Modified: 2013-08-06
Hello,

I have a reserved seating app that needs to allow the user to define section, row, seat based on a database that contains a list of available seats. The repeater looks like this...

Ticket 1   [ddlSection]  [ddlRow]  [ddlSeat]
Ticket 2   [ddlSection]  [ddlRow]  [ddlSeat]
Ticket 3   [ddlSection]  [ddlRow]  [ddlSeat]

If the user selects section from Ticket1.ddlSection, the Ticket1.ddlRow should update based on available rows in the section. How do I handle this? Do I use the ItemCommand of the repeater? How do I get the "onselectedindexchanged" to fire within the repeater? Any help would be appreciated. Please include a little example code.
0
Comment
Question by:tatton777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:Jitendra Patil
ID: 39259010
can you post your code here, so we can review and extend it for your solution.
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 39261003
What you would be doing is add SelectedIndexChanged for the dropdownlists.
e.g. say these are two dropdownlists inside a repeater:
<asp:DropDownList ID="ddlCategory" runat="server" AppendDataBoundItems="false" DataSourceID="SqlDataSource5"
                     DataTextField="CategoryName" DataValueField="CategoryId" AutoPostBack="true" OnSelectedIndexChanged="ddlCategories_SelectedIndexChanged" >
                 </asp:DropDownList>

<asp:DropDownList ID="ddlProducts" runat="server" DataTextField="ProductName" DataValueField="ProductID" OnSelectedIndexChanged="ddlProducts_SelectedIndexChanged"></asp:DropDownList>

Here's the SelectedIndexchanged for two DDL:

//First DDL
protected void ddlCategories_SelectedIndexChanged(object sender, EventArgs e)
    {
        RepeaterItem row = (RepeaterItem)((sender) as Control).NamingContainer;

        // get the value from the first dropdownlist
        DropDownList ddlCategory = ((sender) as DropDownList);
        int categoryId = Convert.ToInt32(ddlCategory.SelectedValue);
       
        // Get Second dropdown and data for second dropdown passing the first selected value.

        DropDownList ddlProducts = row.FindControl("ddlProducts") as DropDownList;
        //Get data for second ddl and bind it.
        ddlProducts.DataSource =  GetSecondDDL DataBind using FirstDDL Selectedvalue;
        ddlProducts.DataBind();
    }
   //Second DDL
    protected void ddlProducts_SelectedIndexChanged(object sender, EventArgs e)
    {
         //Here you do the same as first but for third ddl.
    }

Open in new window

0
 
LVL 1

Author Comment

by:tatton777
ID: 39263841
Sweet. I'll plug this in to my code an let you now how it goes. Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question