Hi, need help on getting the values from datagridview to textboxes, i am having a datagridview getting data's from SQL which has 4 column and number of rows retrieved from sql, i am having 4 textboxes, i want the datagridview selected row's column values to the textboxes, tried few things which i am getting error.
Kindly advice
Loading

Prabhu RajaRank #861 · 2.6K reputationPosted Oct 6, 2011, 3:56 AM EDT
You may use SelectedIndexChanged() Event of GridView Like,
-----------------------------------------------------------------
If this post helps you, then mark as "Correct Answer"
Thank You
VulpesRank #55 · 29.2K reputationPosted Oct 6, 2011, 10:49 AM EDT
Andrew Mills3 reputationPosted Sep 22, 2015, 11:16 AM EDT
// The following code works perfect for me:
private void dgvCustomers_SelectionChanged(Object sender, EventArgs e)
{
MessageBox.Show("SelectionChanged event happened!");
DataGridViewRow row = this.dgvCustomers.SelectedRows[0];
txtID.Text = row.Cells[0].Value.ToString();
txtFirst.Text = row.Cells[1].Value.ToString();
txtLast.Text = row.Cells[2].Value.ToString();
}
//BUT, you must enter the following line in the load event
// to 'wire up' the event as there is nothing on the form
// in design view to double-click on to do this!
dgvCustomers.SelectionChanged += dgvCustomers_SelectionChanged;
Munesh SharmaRank #174 · 13.9K reputationPosted Sep 22, 2015, 9:34 PM EDT