Get the cell value of a GridView row

后端 未结 8 1046
灰色年华
灰色年华 2021-01-01 18:23

I am using the GridView - AutoGenerateSelectButton = \"True\" to select the row in order to get the Column 1 cell value.

I have tried:

         


        
相关标签:
8条回答
  • 2021-01-01 19:06

    I was looking for an integer value in named column, so I did the below:

    int index = dgv_myDataGridView.CurrentCell.RowIndex;
    
    int id = Convert.ToInt32(dgv_myDataGridView["ID", index].Value)
    

    The good thing about this is that the column can be in any position in the grid view and you will still get the value.

    Cheers

    0 讨论(0)
  • 2021-01-01 19:08

    Have you tried Cell[0]? Remember indexes start at 0, not 1.

    0 讨论(0)
提交回复
热议问题