0
votes

I am working with Aspxgridview with contrxtmenustrip in web application. In aspxgridview there are 5 columns with some row data. Post right click on grid I need to know which row user has clicked and what is the column name without passing the column index manually in code level.

int rowVisibleIndex = int.Parse(hf["VisibleIndex"].ToString());

By doing this I am able to get the row number. In the same way I need the column name which is selected by user at client side.

1

1 Answers

0
votes
gridView.Rows['Index of selected row']['Index or column name of cell you want to get value` from']

that in concrete:

gridView.Rows[gridView.SelectedRowIndex]["ID"]

UPDATE and for column Header use this :

private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
    string headerText = dataGridView1.Columns[e.ColumnIndex].HeaderText;
}