[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

2 dropdownlist bounded to each other

Posted on 2006-06-28
4
Medium Priority
?
478 Views
Last Modified: 2012-05-05
In ASP.NET 2.0 I have a page with a formview in EditMode and in it 2 dropdownlist that one is a controll paramete
for the other. One is Country and it is a parameter for  the second. I can't make the second dropdownlist a bound field because if I do it when I change the country in the country dropdown list I get an error. How to deal with a situation like
this. Can the second Dropdoenlist be bounded? withe a BInd value?
Thank you.
I hope to get answer soon because lately I don't.
Anat
0
Comment
Question by:ANAT2403
[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
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
osiris247 earned 1000 total points
ID: 17029534
Hi Anat.

I sometimes get similar problems when having a cascading style drop down binding scenario.

What i do is to bind to the first drop down as you have.  Then instead of setting the binding on the second drop down using the wizards, do it manually in the index changed event....
protected void ddlOne_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlDivision.SelectedIndex > 0) {
            //instance of table adapter....
            dsAreaStructureTableAdapters.CLE_RetrieveAreaByIdDivisionTableAdapter ta = new             dsAreaStructureTableAdapters.CLE_RetrieveAreaByIdDivisionTableAdapter();

            // This is if you want to add 'All' to the top of the dropdowns items.
            this.ddlTwo.Items.Clear();
            this.ddlTwo.Items.Add("All");
            this.ddlTwo.AppendDataBoundItems = true;
            this.ddlTwo.DataTextField = "NameField"; // Set the field names to bind to the correct fields on the drop down.
            this.ddlTwo.DataValueField = "IdField";
            this.ddlTwo.DataSource = ta.GetData(int.Parse(ddlOne.SelectedValue)); // get the data from the table adapter using the selected value from ddlOne
            this.ddlTwo.DataBind(); //Finally bind the data
        }
}

Hope this helps.

Steve
0
 
LVL 7

Expert Comment

by:osiris247
ID: 17029539
Forgot to change the names of the table adapters to something generic........this code i c & p'ed from my own.

should be something like.... TableAdapterClass.TableAdapterName ta = new TableAdapterClass.TableAdapterName;

Steve
0
 

Author Comment

by:ANAT2403
ID: 17029808
Hi,
OK first I wanted to be sure that the second dropdownlist has to be treated manually and I see that it is so.
I did it maually but in a different way . I used  hiddenfields to keep values after the selectedindexchanged
and also in loading.
Anat
0
 
LVL 7

Expert Comment

by:osiris247
ID: 17030707
OK, i am not sure what if anything you are asking here?  Maybe its just my Monday morning, gutted about the football thing!!! :)

Steve
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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