Solved

asp.net/ascx

Posted on 2011-09-24
3
329 Views
Last Modified: 2012-06-27
The attached codes came from ascx code behind.
My issue is I don't know how to create public class in get/set
with the dynamic city/state pairs. The codes basically have dropdown from 1 to 25
and value is used to determine how many pairs of city/state textbox will be shown up.
 
CityTextBox.ID = "City_" + i;
StateTextBox.ID = "State_" + i;

I will need to get get/set like
public int TotalLocation { get { return int.Parse(DdlTotalLocation.Text); } }

Please help me and see you can finish my rest of the tasks.

Thanks,

500 pts for working codes.
protected void DdlTotalLocation_SelectedIndexChanged(object sender, EventArgs e)
    {
        int TotalLocationCount = int.Parse(DdlTotalLocation.SelectedValue);
        if (TotalLocationCount >= 1)
        {
            LblCityStateList.Visible = true;
            for (int i = 0; i < TotalLocationCount; i++)
            {
                //TextBox CityTextBox = new TextBox();
                Obout.Interface.OboutTextBox CityTextBox = new Obout.Interface.OboutTextBox();
                CityTextBox.ID = "City_" + i;
                CityTextBox.Width = 170;
                CityTextBox.TabIndex = 1;
                //TextBox StateTextBox = new TextBox();
                Obout.Interface.OboutTextBox StateTextBox = new Obout.Interface.OboutTextBox();
                StateTextBox.ID = "State_" + i;
                StateTextBox.Width = 100;
                StateTextBox.TabIndex = 2;
                DivSelectCity.Controls.Add(CityTextBox);
                DivSelectState.Controls.Add(StateTextBox);
            }
        }
        else
            LblCityStateList.Visible = false;
    }
    //=====================================================================================
    public int TotalLocation { get { return int.Parse(DdlTotalLocation.Text); } }

Open in new window

0
Comment
Question by:Webboy2008
[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
  • 2
3 Comments
 
LVL 15

Expert Comment

by:Eyal
ID: 36594212
need clarification here...
would you like TotalLocation to return you the total lines generated by DdlTotalLocation_SelectedIndexChanged?
0
 

Author Comment

by:Webboy2008
ID: 36594282
yes
0
 
LVL 15

Accepted Solution

by:
Eyal earned 500 total points
ID: 36594302
what DdlTotalLocation.Text returns?
what DivSelectState.Controls.Count returns?

if that didn't helped the simplest solution I can offer is to create a hidden field (session can be another alternative) in the form and use it for that.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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