I am using the WebDataGrid, not the UltraWebDataGrid and I cant hide some columns of my grid.I want
to hide then at the grid prerender if this is possible.Mu columns are dynamically bounded and have no
specified keys.can anybody help me to hide some columns and rows?
Here is the solution:
VB.NET
Protected Sub WebDataGrid1_InitializeRow(sender As Object, e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles WebDataGrid1.InitializeRow
If e.Row.Index = 0 Then
e.Row.Items.FindItemByKey("CSMainID").Column.Hidden = True
End If
End Sub
C#
protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e) { if (e.Row.Index == 0) { e.Row.Items.FindItemByKey("CSMainID").Column.Hidden = true; } }
I find it disappointing:
1) That you would suggest that there is no way to hide columns when it is documented in the help. http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.2/CLR4.0/html/WebDataGrid_Hiding_a_Column.html
2) That this clearly was available since 2011.2 and I've upgraded to 2012 and this still isn't working.
I get this error when using the Hidden property available for a BoundDataField:
[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).] System.Web.UI.ControlCollection.Add(Control child) +11415588 Infragistics.Web.UI.Framework.AppStyling.CssBuilder.OnPreRenderComplete(Object sender, EventArgs e) +742 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4543
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
The reason for the need to hide columns is to have the data readily available whether it be in the browser or on the server. Most of my applications with the UltraWebGrid relied on this functionality. It looks like Bunty's solution should work, but this is something the grid should be doing on it's own. It's the sole purpose of buying 3rd party controls is to prevent us from having to create hacks for a usable UI.
You can Use the following Code:
this.WebDataGrid1.Columns["ColumnName"].Hidden = true;
This is helpful Bunty. Thank you
Chris,
ChrisKapamaru said:Thanx a lot but I used the UltraWebGrid and had no problems.I have some more questions about Infragistiscs controls.
Normally, I would split a post like this off into its own thread. However, since it's a reply to an earlier post on this thread, and also contains questions about two different controls, I can't simply split it off without doing significant editing.
Thanks for your understanding.