?
Solved

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

Posted on 2013-06-18
3
Medium Priority
?
411 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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