[英]Check if a Column Exists in a RadGrid
This is not finding the column. 这找不到列。 Anyone have any suggestions? 有人有什么建议吗?
if (((RadGrid)sender).Columns.Contains("ClaimNumber"))
do this...
else
do this...
I checked the Columns Collection of the grid and I can see the column there. 我检查了网格的列集合,然后可以在其中看到该列。
You need to use the FindByUniqueNameSafe
method: 您需要使用FindByUniqueNameSafe
方法:
GridColumn col = RadRadGrid1.MasterTableView.Columns.FindByUniqueNameSafe("ColumnName");
if (col != null)
{
//column exists
}
You could also use LINQ: 您还可以使用LINQ:
if (RadGrid1.MasterTableView.Columns.Cast<GridColumn>().Count(x => x.UniqueName == "Column1") > 0)
if (RadGridView.MasterView.ViewTemplate.Columns.Contains("Column")){ Exist}else{ Not-Exist}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.