首页 > 代码库 > .net dropdownlist 動態顯示,指定字段

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


dropdownlist 動態顯示,指定字段
            this.ddlPermission.Items.Clear();
                    this.ddlPermission.Items.Insert(0,new ListItem("請選擇",""));
                    this.ddlPermission.Items.Insert(1,new ListItem("管理01",DEP_ID+"01"));
                    this.ddlPermission.Items.Insert(2,new ListItem("管理02",DEP_ID+"02"));
                    this.ddlPermission.Items.Insert(3,new ListItem("檢視03",DEP_ID+"03"));
                    this.ddlPermission.Items.Insert(4,new ListItem("檢視04",DEP_ID+"04"));
                    this.ddlPermission.Items.Insert(5,new ListItem("檢視05",DEP_ID+"05"));
                    
                    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);
                }