I got a weird problem. I use a DropDownList item in a web application. after i check for the first time one of the options all the items are added to end of the list.
initialized like this
protected void Page_Load(object sender, EventArgs e)
{
string myXMLfile = Server.MapPath("~/VMlist.xml");
DataSet dsMachines = new DataSet();
try
{
dsMachines.ReadXml(myXMLfile);
DropDownList1.DataSource = dsMachines;
DropDownList1.DataValueField = "machineID";
DropDownList1.DataTextField = "machineName";
DropDownList1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
and the SelectedIndexChanged:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
machineOS.Text = OSdata.OSDataRetrieve.getOSInfo(DropDownList1.SelectedItem.Text);
}
i use XML initializing. I’m also adding an image of ‘before’ and ‘after’
You need to add the following to your Page_Load:
Your list is being bound each time the page posts back, which is why you’re getting duplicates. Add the above line, and you should be all set.