private void txt_lec_SelectedIndexChanged(object sender, EventArgs e) { metroGrid1.DataSource = null; metroGrid2.DataSource = null; con.Open(); SqlCommand cmd = new SqlCommand("SELECT Lecturer_no,CONCAT(F_name,' ',L_name),NIC,mobile_no_1,tel_no,email,address FROM Lecture_details WHERE Lecturer_no='" + txt_lec.Text.Split('-').GetValue(0).ToString() + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); lbl_lec_no.Text = dr.GetValue(0).ToString(); lbl_lec_name.Text = dr.GetValue(1).ToString(); lbl_NIC.Text = dr.GetValue(2).ToString(); lbl_mob_no.Text = dr.GetValue(3).ToString(); lbl_tel_no.Text = dr.GetValue(4).ToString(); lbl_email.Text = dr.GetValue(5).ToString(); //lbl_home_no.Text = dr.GetValue(6).ToString(); lbl_street.Text = dr.GetValue(6).ToString(); dr.Close(); /*DataGridViewTextBoxColumn t1 = new DataGridViewTextBoxColumn(); * t1.HeaderText = "Specific Area"; * t1.Name = "Specific Area"; * t1.Width = 250; * metroGrid1.Columns.Add(t1); * DataGridViewTextBoxColumn t2 = new DataGridViewTextBoxColumn(); * t2.HeaderText = "Medium"; * t2.Name = "Medium"; * t2.Width = 250; * metroGrid1.Columns.Add(t2);*/ metroPanel1.Visible = true; General_methods.get_lec_pic(pictureBox1, lbl_lec_no.Text); System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("Lecturer Specific area"); dt.Columns.Add("medium"); metroGrid1.DataSource = d.show("SELECT specific_area FROM Rp_selected_specific_areas WHERE Lec_no='" + lbl_lec_no.Text + "'"); //metroGrid1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; metroGrid3.DataSource = d.show("SELECT Area_preffered_teaching FROM Rp_area_preffered WHERE Lec_no='" + lbl_lec_no.Text + "'"); con.Close(); }