Datagrid Question


This is probably an easy one, i'm just not seeing it

I have a datagrid which has a ButtonColumn among other columns, which gives the option to Delete the row.

The click event, takes me to the ItemCommand event which gives me the index of the row on which the user clicked on. How do I get the ReportID which is what I will use to delete the row.

So say for example we hv the following:
ReportID   Report Desc    Delete
10             abcd               Del (<---)
20             efgh               Del

now if the user clicks on the first Del (with the arrow), the e.Item.ItemIndex = 0, so How do I get the ReportID 10 with that information ?

Who is Participating?
DataGrid dataGrid;
int reportID_col_idx = 0;
string reportID;
reportID = dataGrid[dataGrid.CurrentRowIndex, reportID_col_idx];

You have to know the index of the column you want. In your case, it seems to be 0.
dataGrid[row,col] returns the contents of the col-th column of the row-th row.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.