I have combobox where users can input text or select from a list. When a user inputs their own text, instead it showing up at the bottom or top of the dropdown list, I want it to appear in the correct order. For example if a user types in 24 I want it to apear between 20 and 30.
private void LoadComboBox()
{
if (ddlTypeUnits.SelectedValue == "HP")
{
MotorSizeThreePhase[] motors = MotorSizeThreePhaseFactory.GetList(ActingMotorType, IsHPorBTU, IsAC, true, Common.GetConnectionString());
cmbOutputRating.DataSource = motors;
cmbOutputRating.DataTextField = "MotorSizeHP";
cmbOutputRating.DataValueField = "MotorSizeHP";
cmbOutputRating.DataBind();
}
ThreePhaseMotorLoad curLoad = (ThreePhaseMotorLoad)this.LoadObject;
ListItem item = new ListItem(curLoad.Size.ToString()); //gets the stored size value
if (!cmbOutputRating.Items.Contains(item)) //add the size value to the dropdown list
{
cmbOutputRating.DataBind();
cmbOutputRating.Items.Add(item);
cmbOutputRating.Text = curLoad.Size.ToString();
}
}