I want to fill data on button click event from DataGridView Control:
My code like this
for (int i = 0; i < dgv_EmpAttList.Columns.Count; i++)
{
txt_EnrollNo.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
txt_FirstInTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
txt_LastOutTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
txt_TotalHours.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
}
Why you have to use looping? Simply you can write
EDIT:
Then on Button click send the row to update and write the code as follows
Looping through your columns probably won't help here.
Try assigning each textbox the cell that it is mapped to: