【问题标题】:Check if a Column Exists in a RadGrid检查 RadGrid 中是否存在列
【发布时间】:2011-11-11 16:47:30
【问题描述】:

这不是找到该列。有人有什么建议吗?

if (((RadGrid)sender).Columns.Contains("ClaimNumber"))
    do this...
else
    do this...

我检查了网格的列集合,我可以在那里看到列。

【问题讨论】:

    标签: c# asp.net telerik radgrid telerik-grid


    【解决方案1】:

    你需要使用FindByUniqueNameSafe方法:

    GridColumn col = RadRadGrid1.MasterTableView.Columns.FindByUniqueNameSafe("ColumnName");
    if (col != null)
    {
        //column exists
    }
    

    你也可以使用 LINQ:

    if (RadGrid1.MasterTableView.Columns.Cast<GridColumn>().Count(x => x.UniqueName == "Column1") > 0)
    

    【讨论】:

      猜你喜欢
      • 2013-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多