Skip to main content

ASPxGridBase.GetSelectedFieldValues(String[]) Method

Returns the field values of selected data items (rows, cards, or records).

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web


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


Name Type Description
fieldNames String[]

The names of data source fields.


Type Description

The list of field values.


The GetSelectedFieldValues method allows you to get a single or multiple column values of selected rows.

<dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="CustomerID" AutoGenerateColumns="False">
        <dx:GridViewDataTextColumn FieldName="ContactName" VisibleIndex="0" />
        <dx:GridViewDataTextColumn FieldName="Country" VisibleIndex="4" />
    <SettingsBehavior AllowSelectByRowClick="true" />
// Get a single field value
var selectItems = ASPxGridView1.GetSelectedFieldValues("ContactName");

// Get multiple field values
var selectItems = ASPxGridView1.GetSelectedFieldValues("ContactName", "Country");

View Example: How to get column values of multiple selected rows

To get the values of selected and filtered data items, call the GetSelectedFieldValues(String[]) method.


  • When cell merge is enabled, the GetSelectedFieldValues property is not in effect.


The code sample below calls the GetSelectedFieldValues method to obtain selected rows and deletes them from the grid.

View Example: ASPxGridView - How to Delete Selected Rows in a Grid

<dx:ASPxGridView ID="grid" KeyFieldName="ID" runat="server" AutoGenerateColumns="False"
    ClientInstanceName="grid" OnCustomCallback="gridView_CustomCallback" >
        <dx:GridViewCommandColumn VisibleIndex="0" ShowSelectCheckbox="True">
                <dx:ASPxButton ID="buttonDel" AutoPostBack="false" runat="server" Text="Delete">
                    <ClientSideEvents Click="OnClickButtonDel" />
    <Settings ShowFooter="True" />
function OnClickButtonDel(s, e) {
protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    if(e.Parameters == "Delete") {
        table = GetTable();
        List<Object> selectItems = grid.GetSelectedFieldValues("ID");
        foreach(object selectItemId in selectItems) {

Get the Values of Complex Fields

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.

Web Forms Example

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

MVC Example

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

Get Values in Server Mode

To get the key values of selected and filtered rows in Server Mode, set the SelectionStoringMode property to DataIntegrityOptimized.

If you assign the composite key to the KeyFieldName property, you can pass each key field name as a parameter to the GetSelectedFieldValues method.

In Server Mode, the GetSelectedFieldValues method does not return the non-key values of selected and filtered rows. Use the key values to obtain other values from a database directly:

// For a single key value
query.FirstOrDefault(q => q.KeyProperty == "MyKeyValue")

//For a composite key value
query.FirstOrDefault(q => q.KeyProperty1 == "MyKeyValue1" && q.KeyProperty2 == "MyKeyValue2" && ...)

Online Example

View Example: How to move selected rows between grid controls

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetSelectedFieldValues(String[]) method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also