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
Solved

asp.net/c#/dropdown dynamic

Posted on 2011-09-23
2
236 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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