You need to add the select after you sort.Assuming
adds1
is a
List
of some kind:
for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
{
adds1.Add(ds1.Tables[0].Rows[i].ItemArray[0].ToString().ToLower());
name1 = ds1.Tables[0].Rows[i]["block_name"].ToString().ToLower();
}
adds1.Sort((x, y) => string.Compare(x, y));
adds1.Insert(0, "SELECT");
DropDownList7.DataSource = adds1;
DropDownList7.DataBind();
Note that you need to use
Insert
rather than
Add
to specify where you want "Select" to go. If
add1
is an array or collection that doesn't support
Insert
, the problem is very slightly harder. In this case you should copy the items from the dataset into a new variable (e.g.
tempAdds
), sort
tempAdds
add "Select" to
adds1
, then copy the order values from
tempAdds
.