Get Multiple value from CheckedListbox in C#
For Example:
private void LoadSectionDetails()
{
try
{
DataTable dt;
dt = objSectionDetailsBR.DisplayAll();
if (dt.Rows.Count > 0)
{
chbLSection.DataSource = dt;
chbLSection.DisplayMember = "SectionName";
chbLSection.ValueMember = "SectionID";
}
}
catch (Exception ex)
{
throw ex;
}
}
//To get the value member and display member in Checkedlistbox in C#
foreach (var item in chbLSection.CheckedItems)
{
var row = (item as DataRowView).Row;
int id = row.Field
string name = row.Field
// MessageBox.Show(id + ": " + name);
}
No comments:
Post a Comment
Comments Welcome