[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

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 ?

1 Solution
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.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now