Link to home
Start Free TrialLog in
Avatar of Barry Sweezey
Barry SweezeyFlag for United States of America

asked on

Setting the SelectedIndex of a DropDownList to the first item

I have two dropdown lists, ddlTeam and ddlAgents.  When the user selects a team, ddlAgents contains the agents on that team.  When the user selects a team, I want the selected item in ddlAgents to be the first item.

This code:

    protected void ddlTeam_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.ddlAgents.SelectedIndex = 0;
    }

Generates this error:

'ddlAgents' has a SelectedIndex which is invalid because it does not exist in the list of items.
Parameter name: value
SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I hope I helped somewhat, thanks for the points. :)