Hi @RD , Welcome to Microsoft Q&A,
Updated:
If you want to get rowindex in Gridview of Asp.Net Web Form.
Try using GridView_RowCommand.
The official website has a good example.
I showed how to use dataGridView1_CellClick to query various properties of the selected cell. In the example I show how to select only the type CheckBox.
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex > -1 && e.RowIndex > -1 && e.RowIndex < dataGridView1.Rows.Count)
{
var dc = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
//Determine whether it is a CheckBox column
if (dc.Value is bool cellValue)
{
MessageBox.Show($"RowIndex:{e.RowIndex} ColumnIndex:{e.ColumnIndex} Value:{cellValue}");
}
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.