Search code examples
c#asp.netdevexpressaspxgridview

How to retrive a cell value from a ASPxGridView in an event?


I have a simple ASPxGridView which fires a OnCustomButtonCallback I have tried the following code:

protected void grid_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e)
{
    MyGridView.Rows[0].Cell[0].Value;
}

But it does not see Rows: ASPxGridView does not contain a definition of Rows

I am using DevExpress. Thank you in advance.

P.S. I'd like to get data from the row in which I clicked the custom button on


Solution

  • You can retrieve a particular column/field values using the ASPxGridView.GetRowValues method and pass the related row's VisibleIndex retrieved from the EventArgs e.VisibleIndex property as a parameter:

    protected void grid_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e) {
        var rowValues = grid.GetRowValues(e.VisibleIndex, "FIELD_NAME_HERE");
    }