private void AddAddressForm_Load(object sender, EventArgs e) { BLCounty bLCounty = new BLCounty(); DataTable dt = new DataTable(); BindingList <CountyModel> lista = new BindingList <CountyModel>(); lista = bLCounty.CountyList(); var source = new BindingSource(lista, null); DACountyGet getCounties = new DACountyGet(); DataTable getCountiesTable = getCounties.getCounty(); comboBoxCounty.ValueMember = "CountyId"; comboBoxCounty.DisplayMember = "CountyName"; comboBoxCounty.DataSource = source; comboBoxGetCity.Enabled = false; }
public BindingList <CountyModel> CountyList() { BindingList <CountyModel> listaCounties = new BindingList <CountyModel>(); DataTable dt = new DataTable(); DACountyGet da = new DACountyGet(); dt = da.getCounty(); for (int i = 0; i < dt.Rows.Count; i++) { CountyModel county = new CountyModel(); county.CountyId = Convert.ToInt32(dt.Rows[i]["CountyId"].ToString()); county.CountyName = dt.Rows[i]["CountyName"].ToString(); listaCounties.Add(county); } return(listaCounties); }