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 1, 2011

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250