protected void AddValue_Click(object sender, System.EventArgs e) { DataTable dt = DictionaryItemsTable; if (dt == null) { dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("Id", typeof(int)), new DataColumn("Value", typeof(string)) }); } if (MetaMultiValueCtrl.Items.FindByText(MetaValueCtrl.Text) == null) { DataRow row = dt.NewRow(); row["Id"] = -1; row["Value"] = MetaValueCtrl.Text; dt.Rows.Add(row); DictionaryItemsTable = dt; } this.MetaMultiValueCtrl.DataSource = dt; this.MetaMultiValueCtrl.DataBind(); MetaValueCtrl.Text = String.Empty; if (MetaObject != null) { MetaDictionaryItem[] items = MetaObject.GetDictionaryItems(MetaField); foreach (MetaDictionaryItem item in items) { ManagementHelper.SelectListItem(MetaMultiValueCtrl, item.Id, false); } } }
private void BindData() { //foreach(string item in MetaField.DictionaryItems.Values) //{ // MetaMultiValueCtrl.Items.Add(new ListItem(item, item)); //} if (this.IsPostBack && DictionaryItemsTable != null) { MetaMultiValueCtrl.DataSource = DictionaryItemsTable; MetaMultiValueCtrl.DataBind(); } else { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("Id", typeof(int)), new DataColumn("Value", typeof(string)) }); MetaDictionary dictionary = MetaField.Dictionary; if (dictionary != null) { foreach (MetaDictionaryItem item in dictionary) { DataRow row = dt.NewRow(); row["Id"] = item.Id; row["Value"] = item.Value; dt.Rows.Add(row); } } DictionaryItemsTable = dt; this.MetaMultiValueCtrl.DataSource = dt; this.MetaMultiValueCtrl.DataBind(); } //if(MetaField.Value!=null) //foreach(string str in (string[])MetaField.Value) //{ // Util.CommonHelper.SelectListItem(MetaMultiValueCtrl, str, false); //} if (MetaObject != null) { MetaDictionaryItem[] items = MetaObject.GetDictionaryItems(MetaField); foreach (MetaDictionaryItem item in items) { ManagementHelper.SelectListItem(MetaMultiValueCtrl, item.Id, false); } } }