This is a migrated thread and some comments may be shown as answers.

Hide Specific Auto-Generated Columns

3 Answers 230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 2
Brett asked on 08 Jul 2008, 07:06 PM
I am auto-generating my columns, however I want to hide the "ID" column.  Can this be done without specifically defining the column ?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jul 2008, 05:10 AM
Hi,

You can hide the AutoGeneratedColumns in the ColumnCreated event as shown below.

CS:
 protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column is GridBoundColumn) 
        { 
            GridBoundColumn col = (GridBoundColumn)e.Column; 
            if (col.UniqueName == "ID") 
            { 
                col.Visible = false
            } 
        } 
    } 


Thanks
Shinu.
0
Brett
Top achievements
Rank 2
answered on 09 Jul 2008, 03:16 PM
Thanks Shinu, works great!
0
Liza
Top achievements
Rank 1
answered on 19 Jan 2009, 05:33 PM
Hi!! I hope you can help me!!
I was trying to do what you said before but, I always got the same error:

Error de servidor en la aplicación '/GP'.

Colección modificada; puede que no se ejecute la operación deenumeración.

Descripción:Excepción no controlada al ejecutar la solicitud Web actual. Revise elseguimiento de la pila para obtener más información acerca del error y dónde seoriginó en el código.

Detalles de la excepción:System.InvalidOperationException: Colección modificada; puede que no seejecute la operación de enumeración.

Error de código fuente:

Se ha generado una excepción no controlada durante la ejecución de la solicitud Web actual. La información sobre el origen y la ubicación de la excepción pueden identificarse utilizando la excepción del seguimiento de la pila siguiente.

Seguimiento de lapila:

[InvalidOperationException: Colección modificada; puede que no se ejecute la operación de enumeración.]  
System.Web.UI.ControlCollectionEnumerator.MoveNext() +8648494   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +143  
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10   
Telerik.Web.UI.RadCompositeDataBoundControl.RenderContents(HtmlTextWriter writer) +46   
Telerik.Web.UI.RadGrid.RenderContents(HtmlTextWriter writer) +56   
Telerik.Web.UI.RadGrid.Render(HtmlTextWriter writer) +174   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
Telerik.Web.UI.ControlRenderer.Render(HtmlTextWriter writer) +84   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27  
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.Control.Render(HtmlTextWriter writer) +10   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer) +238   
System.Web.UI.Control.Render(HtmlTextWriter writer) +10   
System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer) +35   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
Telerik.Web.UI.PreControlToAjaxify.Render(HtmlTextWriter writer) +112   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.Control.Render(HtmlTextWriter writer) +10   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
Telerik.Web.UI.ControlRenderer.Render(HtmlTextWriter writer) +84   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.Control.Render(HtmlTextWriter writer) +10   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer) +238   
System.Web.UI.Control.Render(HtmlTextWriter writer) +10   
System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer) +35   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
Telerik.Web.UI.PreControlToAjaxify.Render(HtmlTextWriter writer) +112   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163   
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32   
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.Control.Render(HtmlTextWriter writer) +10   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.Page.Render(HtmlTextWriter writer) +29   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +640   
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256   
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19   
System.Web.UI.Page.Render(HtmlTextWriter writer) +29   
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99   
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25   
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
            


Información de versión: Versión de Microsoft .NETFramework:2.0.50727.3053; Versión ASP.NET:2.0.50727.3053 



thanks!!
Tags
Grid
Asked by
Brett
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Brett
Top achievements
Rank 2
Liza
Top achievements
Rank 1
Share this question
or