We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Datagrid Question

sahnias
sahnias asked
on
Medium Priority
239 Views
Last Modified: 2011-10-03
Hello,

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 ?

Comment
Watch Question

Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.