public void loadToinletProduct(string id) { Connection objC1 = new Connection(); SqlDataAdapter adp; DataSet ds = new DataSet(); DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from tblstudent where stuid=" + id; cmd.CommandType = CommandType.Text; cmd.Connection = objC1.objCon; try { objC1.objCon.Open(); adp = new SqlDataAdapter(cmd); adp.Fill(ds); dt = ds.Tables[0]; //Set AutoGenerateColumns False dataGridView2.AutoGenerateColumns = false; //Set Columns Count //dataGridView1.Refresh(); dataGridView2.ColumnCount = 7; // //Add Columns //dataGridView2.Columns[0].Name = "productName"; //dataGridView2.Columns[0].HeaderText = "Product"; //dataGridView2.Columns[0].DataPropertyName = "productName"; which code to display in gridview in textbox dataGridView2.DataSource = dt; } catch (Exception ei) { MessageBox.Show(ei.Message); } finally { objC1.objCon.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)