When using the telerik RadGrid, imagine you want to bind data dynamically and hide some necessary columns from the grid.
When your are trying to hide the column you need to check whether the column exists first. Other wise Radgrid will throw the exception "Telerik.Web.UI.GridException: Cannot find a column with UniqueName 'YourColumn'".
This error occurs if you use the below code to find a column in the RadGrid
RadGrid1.MasterTableView.GetColumn("YourColumn")
To avoid the exception use the below code.
GridColumn g3 = (GridColumn)gridSearchL3.MasterTableView.Columns.FindByUniqueNameSafe("YourColumn");
if (g3 != null)
g3.Visible = false;
This will not throw the exception and returns null if the column was not found.
Monday, December 17, 2012
Check Column Exists in RadGrid
Subscribe to:
Post Comments (Atom)
No comments:
Write comments