Link to home
Start Free TrialLog in
Avatar of ocdc
ocdcFlag for United States of America

asked on

How do I make an inserted item in my drop down list into 2nd position on the list?

I would like to make "**Manager Positions" 2nd on my list of my dynamic drop down list.  Currently, "--Select Position Title--" is in the first position, and "**Manager Positions" is in last position.

 
protected void SetValue2(object sender, EventArgs e)
    {
        DropDownList ddl = (DropDownList)sender;
        if (filter != null)
        {
            ddl.Items.Insert(0, new ListItem("--Select Position Title--"));
            ddl.Items.Add(new ListItem("**Manager Positions"));
            if (filter.ContainsKey("Position_Title"))
            {
                foreach (ListItem li in ddl.Items)
                {
                    if (li.Text == filter["Position_Title"].ToString().Substring(2, filter["Position_Title"].ToString().Length - 3))
                    {
                        li.Selected = true;
                        return;
                    }
                }
            }
        }
    }
ASKER CERTIFIED SOLUTION
Avatar of malikirfan28
malikirfan28

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
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
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
Avatar of malikirfan28
malikirfan28

But there is 1 minute difference between comments :).
Avatar of ocdc

ASKER

Thanks guys.  I appreciate it.