I have a project in winforms and in my RegisterStudent form I have a combobox that hold education column.Based on the selection from the combobox,a selection of checkboxes will appear.The problem is that when i want to select a value from the combobox,i can't.Instead the courses for the default value appears.This is my method to load data into the combobox:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
LoadEducation();
}
private void LoadEducation()
{
using (SqlConnection conn = new SqlConnection(connstr))
{
try
{
string query = "select education from AvailableCourses";
da = new SqlDataAdapter(query, conn);
conn.Open();
ds = new DataSet();
da.Fill(ds, "AvailableCourses");
comboBoxEducation.DisplayMember = "education";
comboBoxEducation.ValueMember = "education";
comboBoxEducation.DataSource = ds.Tables["AvailableCourses"];
}
catch (Exception ex)
{
MessageBox.Show("Error occured!");
}
}
}
And this is the table from where i take the data:
CREATE TABLE [dbo].[AvailableCourses](
[CourseID] [char](10) NOT NULL,
[ClassID] [nvarchar](50) NULL,
[courseName] [nvarchar](50) NOT NULL,
[education] [nvarchar](50) NOT NULL,
PRIMARY KEY CLUSTERED
(
[CourseID] ASC
What I have tried:
Does anybody have any idea why is not working?I have also tried with SelectedIndex and SelectedValue but for nothing,it won't do anything.Thank you in advance.