I have been utilizing the asp:gridview and use this syntax to determine which columns to hide:
private int GetColumnIndex(GridView grid, string ColName)
{
foreach (DataControlField col in grid.Columns)
{
if (col.HeaderText.ToLower().Trim() == ColName.ToLower().Trim())
{
return grid.Columns.IndexOf(col);
}
}
return -1;
}
Now when converting to radgrid I get the error of
'Unable to cast object of type 'Telerik.Web.UI.GridBoundColumn' to type 'System.Web.UI.WebControls.DataControlField'.'
With the below syntax:
private int GetColumnIndexRad(Telerik.Web.UI.RadGrid grid, string colName)
{
foreach (DataControlField col in grid.Columns)
{
if (col.HeaderText.ToLower().Trim() == colName.ToLower().Trim())
{
return grid.Columns.IndexOf(col);
}
}
return -1;
}
What would be the proper way to conditionally hide columns based off a check box list selection?