Datagrid Question

Posted on 2006-04-04
Last Modified: 2011-10-03

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 ?

Question by:sahnias
    1 Comment
    LVL 5

    Accepted 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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now