Solved

asp.net/c#/dropdown dynamic

Posted on 2011-09-23
2
233 Views
Last Modified: 2012-06-27
I have attached codes and have dropdown in aspx frontend.
What I really want to do is to put city/state in into placeholder inside of <div></div>
and show on the aspx.

How can I connect them?
How can I validate city/state? Assume if I select 5 in dropdown.
5 pairs of city/state will be shown. and I need to make sure the user enters all 5 pairs.

Thanks
protected void DdlTotalLocation_SelectedIndexChanged(object sender, EventArgs e)
    {
        int TotalLocationCount = int.Parse(DdlTotalLocation.SelectedValue);
        for (int i = 0; i < TotalLocationCount; i++)
        {
            TextBox CityTextBox = new TextBox();
            CityTextBox.ID = "City_" + i;
            TextBox StateTextBox = new TextBox();
            StateTextBox.ID = "State_" + i;

        }

    }

Open in new window

0
Comment
Question by:Webboy2008
2 Comments
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 36590721
aspx:

<div id=divSelect runat=server></div>

C# Line 10:

divSelect.Controls.Add(CityTextBox);
divSelect.Controls.Add(StateTextBox);
divSelect.Controls.Add(New LiteralControl("<br/>");

0
 

Author Comment

by:Webboy2008
ID: 36590728
alert message to this line: divSelect.Controls.Add(New LiteralControl("<br/>");
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now