Advertisement

02.11.2008 at 12:21PM PST, ID: 23154233
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.0

DropDownList SelectedIndexChanged AutoPostBack C# ASP.NET

Asked by famoso in Programming for ASP.NET, Microsoft Visual C#.Net, .NET Framework 2.x

2 DropDownList Boxes (ddStates, ddCounties)
Both are AutoPostBack.
ddStates_SelectedIndexChange says to populate ddCounties.
ddCounties_SelectedIndexChanged says to populate some other DropDownList.

When I select any county other than the first county then everything posts back and counties get reset to the first county.

I understand that the problem should be in ddCounties_SelectedIndexChanged but the problem is cleared up if I use a file to populate counties from ddStates_SelectedIndexChanged opposed to using a DB.

Oddly enough though, if you look at the "This works" code in ddStates_SelectedIndexChanged and use that code instead of the "This doesn't work" code, it works.

What is the difference between using a file as opposed to using a DB?

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
default.aspx
<%@ Page Language="C#" AutoEventWireup="false" Codebehind="default.aspx.cs" Inherits="SmartQueryXML._default" ValidateRequest="false" %>
 
<asp:DropDownList ID="ddStates" runat="server" OnSelectedIndexChanged="ddStates_SelectedIndexChanged" AutoPostBack="True" Width="150px"></asp:DropDownList>
<asp:DropDownList ID="ddCounties" runat="server" Width="150px" OnSelectedIndexChanged="ddCounties_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
 
=================================================
default.aspx.cs
    protected void ddStates_SelectedIndexChanged(object sender, EventArgs e) {
      string ErrorMessage = "";
      string state = ddStates.SelectedItem.Value;
 
      // This doesn't work
      DataSet ds = new DataSet();
      ds = Helper.GetCounties(state, "%%", ref ErrorMessage);
 
      ddCounties.Items.Clear();
      ddCounties.Items.Add(new ListItem("Choose a County", ""));
 
      foreach(DataRow dr in ds.Tables[0].Rows) {
        ddCounties.Items.Add(new ListItem(dr["Name"].ToString(), state));
      }
 
      // This works
      //DataSet ds = new DataSet("Jurisdiction");
      //FileStream fs = new FileStream(Server.MapPath("Jurisdiction.xml"), FileMode.Open, FileAccess.Read);
      //StreamReader sr = new StreamReader(fs);
      //ds.ReadXml(sr);
      //fs.Close();
      //DataView dv = new DataView(ds.Tables[0]);
 
      //dv.Table = ds.Tables[0];
      //dv.RowFilter = "State = '" + state + "'";
      //ddCounties.DataSource = dv;
      //ddCounties.DataMember = "jurisdiction";
      //ddCounties.DataTextField = "county";
      //ddCounties.DataValueField = "county";
      //ddCounties.DataBind();
 
    }
 
    protected void ddCounties_SelectedIndexChanged(object sender, EventArgs e) {
      // Reset inputs when user selects a county
      //  Clean slate.
      string county = ddCounties.SelectedItem.Value;
    }
[+][-]02.11.2008 at 02:12PM PST, ID: 20870818

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.11.2008 at 06:26PM PST, ID: 20872136

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.11.2008 at 09:49PM PST, ID: 20872745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 04:29AM PST, ID: 20874178

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 04:35AM PST, ID: 20874206

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual C#.Net, .NET Framework 2.x
Sign Up Now!
Solution Provided By: famoso
Participating Experts: 3
Solution Grade: A
 
 
[+][-]02.12.2008 at 04:40AM PST, ID: 20874232

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 08:48PM PST, ID: 20881717

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628