Iam retrieving record from table and adding to the datagridview. When i select another record, the reterived record must be added to the next row.
Here's my code.
con = new SqlConnection("Data Source=(local);Initial Catalog=Pharmaceuticals;Integrated Security=True");
con.Open();
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = con;
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = "select * from Product_Details where Item='" + item_combo.Text + "'";
SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd);
DataTable dtRecord = new DataTable();
sqlDataAdap.Fill(dtRecord);
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = dtRecord;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
DataTable dt=new DataTable();
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
con.Close();