How to Fill TextBoxes from DataGridView on Button Click Event

前端 未结 2 1805
时光取名叫无心
时光取名叫无心 2021-01-24 12:56

I want to fill data on button click event from DataGridView Control:

\"enter

My co

2条回答
  •  抹茶落季
    2021-01-24 13:48

    Why you have to use looping? Simply you can write

     txt_EnrollNo.Text = this.dgv_EmpAttList.CurrentRow.Cells[0].Value.ToString(); 
    txt_FirstInTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[1].Value.ToString();
    txt_LastOutTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[2].Value.ToString();
     txt_TotalHours.Text = this.dgv_EmpAttList.CurrentRow.Cells[3].Value.ToString(); 
    

    EDIT:

    Then on Button click send the row to update and write the code as follows

    txt_EnrollNo.Text = row.Cells[0].Value.ToString(); //where row is DataGridViewRow
    

提交回复
热议问题