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 (System.data.datarow)

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);
                    con.Open();
                    SqlDataReader sdr = cmd.ExecuteReader();
                    dtrecordCB.Load(sdr);

                }
                return dtrecordCB;
            }
        }

please guide

You are viewing reply posted by: pandeyism 9 days ago.