Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried but it is not working.

Faculty Code combo box view(Button)


private void Btn_View_Course_Click(object sender, EventArgs e)
{
sql = "select Date,Session,Course from Tb_SCh_TIme_Table where Faculty_Code= ' " + Cb_Faculty_Code.Text + "'order by Date,session ";


DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(sql, con);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
da.Fill(dt);
dataGridView1.DataSource = dt;
}

in the data base records are there.

when i select the Faculty_Code and click the View Button .the particular Faculty_Code details want to display in datagridview1.

select the Faculty_Code and click the view (Button).

in the datagridview1 the Faculty_Code details is not display in the data grid view.

from my code wat is the mistake.how can i do.
Posted

1 solution

you should bind data to the data grid view.

private void Btn_View_Course_Click(object sender, EventArgs e)
{
sql = "select Date,Session,Course from Tb_SCh_TIme_Table where Faculty_Code= ' " + Cb_Faculty_Code.Text + "'order by Date,session ";
 

DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(sql, con);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
da.Fill(dt);
dataGridView1.DataSource = dt;
dataGridView1.DataBind();
}


Hope this will help u on ur problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900