When I click on first row (first cell) of DataGridView1 then corresponding items is displayed in another DataGridView2.
Similarly When I click on second row (first cell) of DataGridView1 then corresponding items is displayed in another DataGridView2.
Similarly When I click on third row (first cell) of DataGridView1 then corresponding items is displayed in another DataGridView2.
I mean to say that when click on the Cell items(row wise) of the DataGridView control of window application then other information should be displayed.
Should I use cell_click method or row_click method.What method is suitable?
So what is the code for it. Tell me.
I m using this code but it is not working properly.
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
string connectionString = ConfigurationSettings.AppSettings["cnn"];
string selectSQL = "SELECT middle,company,title FROM contactmngt where id= '" + e.RowIndex + "'";
SqlDataAdapter adp = new SqlDataAdapter(selectSQL, cnn);
SqlCommandBuilder cmd = new SqlCommandBuilder(adp);
DataTable dtusers = new DataTable();
//Session["id1"] = dr["id"].ToString();
//Fill data table
adp.Fill(dtusers);
DataRow dr = dtusers.Rows[0];
//Panel1.Visible = true;
dataGridView3.DataSource = dtusers;
//Resize the Datagridview column to fit the gridview columns with data in datagridview
dataGridView3.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
catch (Exception)
{
//MessageBox.Show();
}
}