ocdc
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("Posit ion_Title" ))
{
foreach (ListItem li in ddl.Items)
{
if (li.Text == filter["Position_Title"].T oString(). Substring( 2, filter["Position_Title"].T oString(). Length - 3))
{
li.Selected = true;
return;
}
}
}
}
}
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("Posit
{
foreach (ListItem li in ddl.Items)
{
if (li.Text == filter["Position_Title"].T
{
li.Selected = true;
return;
}
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But there is 1 minute difference between comments :).
ASKER
Thanks guys. I appreciate it.