Bind (Populate) DropDownList from Database in Windows Forms using C# and VB.Net

Last Reply 9 days ago By pandeyism

Posted 9 days ago

i am trying to load data in dropdownlist but it is not getting load and coming this (

here is my c# Code 

        private void LoadDataintoComboBox()
            CateogryComboBox.DataSource = GetComboBoxData(3);
            ProductComboBox.DataSource = GetComboBoxData(2);

        private DataTable GetComboBoxData(int listTypeID)
            DataTable dtrecordCB = new DataTable();
            using (SqlConnection con = new SqlConnection(ApplicationSetting.ConnectionString()))
                using (SqlCommand cmd = new SqlCommand("usp_ListTypeData_LoadDataIntoCombobox", con))
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@listTypeID", listTypeID);
                    SqlDataReader sdr = cmd.ExecuteReader();

                return dtrecordCB;

please guide