I am beginner to the dot.net, can any one suggest me how to remove specific value in fetched dropdown list.
Here why I am mentioning fetched means that dropdownlist is generated from or fetched from a table using sql.
sqlquery=SELECT DISTINCT rtrim(ltrim(C.Cust_name)) as Cust_name FROM table1 A inner join table2 B on A.cust_code = B.Cust_Code
SqlCommand cmd = new SqlCommand(sqlquery, conn);
SqlDataReader sr = cmd.ExecuteReader();
while (sr.Read())
{
{
cmb_cust.Items.Add(sr["Cust_name"].ToString());
}
}
foreach (ListItem li in cmb_cust.Items)
{
{
if (li.Value == "value1")
cmb_cust.Items.Remove(li);
}
}
If I process the above statement I facing collection was modified enumeration operation may not execute, can I get the any other solution like swaping the list to temp list and process the operation. I don`t need the value1 after fetching from the sql.