Home > DeveloperSection > Articles > How to populate records in ComboBox

How to populate records in ComboBox

C# C# 
1 Comment(s)
 4479  View(s)
Rate this:

How to populate records in ComboBox in .Net

To populate ComboBox we have to add the values of DataRows to it.


//connecting to database and copying record to DataAdapter

string strConnection = "Server=abc\\SQLEXPRESs;Database=Employee;Trusted_Connection=True";

            SqlConnection con = new SqlConnection(strConnection);


            SqlDataAdapter da = new SqlDataAdapter("select * from employee", con);

            DataSet ds = new DataSet();

            da.Fill(ds, "Employee");

            DataTable dt = ds.Tables["Employee"];

            DataRow row;


//populating combobox.


            for (int i = 0; i < dt.Rows.Count; i++)


//this will run for all rows present in table.                             

                row = dt.Rows[i];


//adding items to combobox one by one.




By Sushant Mishra on   one month ago

It was really helpful to read this post.        

Don't want to miss updates? Please click the below button!

Follow MindStick