views:

16

answers:

1

Hello all

I have the following code that a cascading drop down kicks off with

protected void ddlBuyer_SelectedIndexChanged(object sender, EventArgs e)
{
    FinalProductsDataContext dbII = new FinalProductsDataContext();
    var queryBuyer = (from r in dbII.tblOnlineReportingFINALPRODUCTSNEWDEMOs
                      where r.UnitUserfield1 == ddlBuyer.SelectedValue
                      select new { UnitUserfield2 = r.UnitUserfield2 }).Distinct().OrderBy(r => r.UnitUserfield2);

    ddlSub.DataSource = queryBuyer;
    ddlSub.DataTextField = "UnitUserfield2";
    ddlSub.DataValueField = "UnitUserfield2";
    ddlSub.DataBind();

    GridView1.Columns.Clear();

    tbxProdAC.Text = "";

    radSub.Checked = false;
    radProd.Checked = false;
    radProdAC.Checked = false;

    radBuyer.Checked = true;

    ddlProd.Items.Insert(0, "--Choose Product--");
    ddlSub.Items.Insert(0, "--Choose Sub Category--");

}

On it's first run through, this runs perfectly with ddlProd & ddlSub being populated with "--Choose..."

However, if the user changes ddlBuyer, ddlSub, ddlProd and then back to change the ddlBuyer, ddlSub is populated with "--Choose Sub-Category--" but ddlProd remains as the first item they looked at.

How can I get around this?

A: 

try to add

ddlProd.SelectedIndex = 0;

after

ddlProd.Items.Insert(0, "--Choose Product--");
ikhaldeev
Top stuff ikhaldeev - thank you very much. So simple but so effective.
Ricardo Deano