12 October 2011

Get Multiple value from CheckedListbox in C#



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("SectionID");
                string name = row.Field("SectionName");
              //  MessageBox.Show(id + ": " + name);
            }

No comments:

Post a Comment

Comments Welcome

Finding duplicate records in SQL Server

 Finding duplicate records in SQL Server 1. The GROUP BY and HAVING Method This is the most standard approach. It is best used when you on...