Solved

asp.net/ascx

Posted on 2011-09-24
3
324 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
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 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