List<Site> list = new List<Site>(); foreach (DataRow srcDr in srcDt.Rows) { list.Add(new Site { Text = srcDr["SiteName"].ToString(), Value = (int)srcDr["SiteId"],Identifier = srcDr["identifier"].ToString() }); } CboSite.DisplayMember = "Text"; CboSite.ValueMember = "Value"; CboSite.Tag = "Identifier"; CboSite.DataSource = list;
public class Site { public int Value { get; set; } public string Text { get; set; } public string Identifier { get; set; } }
((Site)CboSite.SelectedItem).Identifier;