.net dropdownlist 動態顯示,指定字段

时间:2023-01-18 13:14:25
dropdownlist   動態顯示,指定字段
            this.ddlPermission.Items.Clear();
this.ddlPermission.Items.Insert(,new ListItem("請選擇",""));
this.ddlPermission.Items.Insert(,new ListItem("管理01",DEP_ID+""));
this.ddlPermission.Items.Insert(,new ListItem("管理02",DEP_ID+""));
this.ddlPermission.Items.Insert(,new ListItem("檢視03",DEP_ID+""));
this.ddlPermission.Items.Insert(,new ListItem("檢視04",DEP_ID+""));
this.ddlPermission.Items.Insert(,new ListItem("檢視05",DEP_ID+"")); foreach(DataRow dr in dt.Rows)
{
this.ddlPermission.Items.Remove(ddlPermission.Items.FindByText(dr["PermissionName"].ToString())); // foreach(ListItem li in this.ddlPermission.Items)
// {
// Response.Write(li.Text);
// //Response.Write("li.text="+li.Text+" <br /> dr="+dr["PermissionName"].ToString());
// if(dr["PermissionName"].ToString()==li.Text )
// {
// this.ddlPermission.Items.Remove(li.Text);
// }
// }
}
Response.Write("<br />"+this.ddlPermission.Items.Count);
}