Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 2.8 KB

File metadata and controls

54 lines (40 loc) · 2.8 KB

Grid View for ASP.NET Web Forms - How to get column values of multiple selected rows.

This example demonstrates how to use the server-side GetSelectedFieldValues method to obtain field values of multiple selected rows.

GetSelectedFieldValues

Overview

Follow the steps below:

  1. Set the grid's AllowSelectByRowClick property to true to enable row selection.

    protected void Page_Init(object sender, EventArgs e) {
        // ...
        ASPxGridView1.SettingsBehavior.AllowSelectByRowClick = true;
        // ...
    }
  2. In a button's Click event handler, call the GetSelectedValues function. In this function, get the field names of grid columns and call the GetSelectedFieldValues method to obtain the field values of selected rows.

    protected void ASPxButton1_Click(object sender, EventArgs e) {
        GetSelectedValues();
        // ...
    }
    
    List<object> selectedValues;
    
    private void GetSelectedValues() {
        List<string> fieldNames = new List<string>();
        foreach(GridViewColumn column in ASPxGridView1.Columns)
            if(column is GridViewDataColumn)
                fieldNames.Add(((GridViewDataColumn)column).FieldName);
        selectedValues = ASPxGridView1.GetSelectedFieldValues(fieldNames.ToArray());
    }

Files to Review

Documentation