GridControl获取选中行的ID或者获取选中行的实体类

通过列名获取选中行的ID

private string GetSelectID(string FileName)
{
int[] pRows = this.gdv.GetSelectedRows();//传递实体类过去 获取选中的行
if (pRows.GetLength(0) > 0)
return gdv.GetRowCellValue(pRows[0], FileName).ToString();
else
return null;
}

GetSelectID(string FileName)//调用的时候直接传入想要获取的单元格的列名

获取实体类

List<EntityEmployee> entityEmployees = new List<EntityEmployee>();

var list = gridControl.DataSource as List<EntityEmployee>;获取到当前GridControl中绑定的数据源List<EntityEmployee>;

if (list == null || list.Count == 0) { return; }判断获取到的list集合是否为空

entityEmployees = list.FindAll(t => t.IsUpdate);在按条件进行筛选得到实体类

猜你喜欢

转载自www.cnblogs.com/yourSixUncle/p/9922442.html