protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.CategoryID.DataSource = Category.selectC(); CategoryID.DataBind(); } }
private void BindCatelog() { DictManager dictManager = new DictManager(); DataTable dt = new DataTable(); dt.Columns.Add("ID", Type.GetType("System.String")); dt.Columns.Add("Name", Type.GetType("System.String")); DataTable dt2 = dictManager.GetDictList("04"); foreach (DataRow row in dt2.Rows) { DataRow newRow = dt.NewRow(); newRow["ID"] = row["ID"].ToString(); newRow["Name"] = row["Name"]; dt.Rows.Add(newRow); } CategoryID.DataSource = dt; CategoryID.DataTextField = "Name"; CategoryID.DataValueField = "ID"; CategoryID.DataBind(); }