Article From:https://www.cnblogs.com/zhaogaojian/p/9215286.html

1、Direct assignment

foreach (DataRow dr in ds.Tables[0].Rows)  //Traversing two values
{
    Ext.Net.ListItem listItem = new Ext.Net.ListItem();         //Create an object of Ext.Net.ListItem each time
    listItem.Value = dr["ID"].ToString();
    listItem.Text = dr["Name"].ToString();
    drpComBox.Items.Add(listItem);
}

2、Set the selected item. Note that this method can not be used in Store mode.

public void SetListValue(ComboBox p_rg, string p_value)
{
     int num = 0;
     foreach (ListItem listItem in (StateManagedCollection<ListItem>)p_rg.Items)
     {
         if (listItem.Value == p_value)
         {
              p_rg.SelectedIndex = num;
              ExtNet.AddScript(string.Format("{0}.setValue(\"{1}\");", (object)p_rg.ClientID.ToString(), (object)p_value));
              break;
          }
          ++num;
      }
}

3、Using Store

this.drpComBox.DisplayField = "Name";
this.drpComBox.ValueField = "ID";
this.drpComBOx.StoreID = "storeStudent";
 protected void storeStudent_Refresh(object sender, StoreRefreshDataEventArgs e)
 {
     ..
     storeStudent.DataSource = ds.Tables[0];
     storeStudent.DataBind();

 }

 set currency

this.drpComBox.SetValue(Id);
this.drpComBox.Text = v.Name

 

Link of this Article: Extjs.net Combox assignment

Leave a Reply

Your email address will not be published. Required fields are marked *