设置选中与隐藏某项
private void SetSelectedItem(System.Web.UI.WebControls.DropDownList list, string selectparam)
{
string sql_select;
sql_select = "select * from type_news where parentid=0 ";
DataSet ds = DBHelper.Valueset(sql_select);
list.DataSource=ds.Tables[0];
//list.Items.Remove("--新建类别--");
//list.Items.Insert(0, new ListItem("------", "-1"));
list.DataTextField = "typename";
list.DataValueField = "typeid";
list.DataBind();
foreach (ListItem e in list.Items)
{
//ListItem item = list.Items.FindByValue(Nshow);
if (e.Value.ToString() == selectparam)
{
e.Selected = true;
return;
}
else e.Selected = false;
}
}