Articles → .NET → Binding combo box using generic class

Binding combo box using generic class









using System;
public class Country {
	public int CountryID {
		get;
		set;
	}
	public string CountryName {
		get;
		set;
	}
}








public List < Country > CountryCollection {
	get;
	set;
}




CountryCollection = new List<Country>();
Country CountryObject = new Country();
CountryObject.CountryID = 1;
CountryObject.CountryName = "India";
CountryCollection.Add(CountryObject);

CountryObject = new Country();
CountryObject.CountryID = 2;
CountryObject.CountryName = "Sri Lanka";
CountryCollection.Add(CountryObject);

CountryObject = new Country();
CountryObject.CountryID = 3;
CountryObject.CountryName = "Australia";
CountryCollection.Add(CountryObject);

comboBox1.DataSource = CountryCollection;





Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, February 01, 2011

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250