Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

asp.net/ascx

Posted on 2011-09-24
3
Medium Priority
?
336 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 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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