Skip to main content

ASPxGridBase.GetSelectedFieldValues(String[]) Method

Returns the values displayed in all selected data items (rows, cards or records).

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.1.dll


public List<object> GetSelectedFieldValues(
    params string[] fieldNames


Name Type Description
fieldNames String[]

The names of data source fields whose values are returned.


Type Description

The list of objects that contain values displayed in the selected data items.


Use the GetSelectedFieldValues method to get a single column as well as multiple column values of selected rows.

To get keys (including compound key values) of selected rows that were filtered when the grid operates in Server Mode, do the following:

  • Set the ASPxGridBehaviorSettings.SelectionStoringMode property to GridViewSelectionStoringMode.DataIntegrityOptimized.
  • Set a field whose names are sent as inner parameters to the GetSelectedFieldValues method as a key field. If you have assigned a compound KeyFieldName, you can use all the key field names as inner parameters of the GetSelectedFieldValues method.
  • Use key field values to obtain other row values from a database directly, since the GetSelectedFieldValues method does not return non-key values of selected rows in Server mode.

For a single key:

query.FirstOrDefault(q => q.KeyProperty == "MyKeyValue")

For a compound key:

query.FirstOrDefault(q => q.KeyProperty1  == "MyKeyValue1" && q.KeyProperty2 == "MyKeyValue2" && ...)


  • The GetSelectedFieldValues property is not in effect if cell merging is enabled.
  • The GetSelectedFieldValues method returns column values only. So, if a grid is bound to a collection of complex objects (for example, KeyFieldName=”Product.Category.CategoryName”), create a hidden column for this complex field. The grid does not render hidden columns, but allows you to get their data on the server side.

    MVC approach:

    settings.Columns.Add("SubRegionInfo.ID").Visible = false;

    Web Forms approach:

    ASPxGridView1.Columns.Add("SubRegionInfo.ID").Visible = false;

The following example illustrates how to use the GetSelectedFieldValues method to obtain the “ProductName” field’s value of the ASPxGridView’s selected row.

protected void ASPxButton1_Click(object sender, EventArgs e)
    var products = ASPxGridView1.GetSelectedFieldValues("ProductName");
    ASPxLabel1.Text = products[0].ToString();


See Also