Solved

asp.net/ascx

Posted on 2011-09-24
3
311 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
  • 2
3 Comments
 
LVL 15

Expert Comment

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

Author Comment

by:Webboy2008
Comment Utility
yes
0
 
LVL 15

Accepted Solution

by:
Eyal earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

16 Experts available now in Live!

Get 1:1 Help Now