在网格上设置客户端实例名称:
ClientInstanceName="YourGrid"
然后在页面上的某个位置添加一个控件,以允许用户“全选”,如下所示:
<input id="chkSelectAll" type="checkbox" onclick="YourGrid.SelectAllRowsOnPage(this.checked);" />
最后在后面的代码中你可以做这样的事情:
// aColumnName is the name of the column from which you want the value.
private List<object> GetSelectedRowValues(string aColumnName)
{
List<object> values = new List<object>();
string[] valueToGet = { aColumnName };
for (int i = 0; i < YourGrid.VisibleRowCount; i++)
{
if (YourGrid.Selection.IsRowSelected(i))
{
//get the passed in value for the selected rows.
values.Add(YourGrid.GetRowValues(i, valueToGet));
}
}
return values;
}