how did i set a column invisible? the data (when i later select some row) i still need.in the old ultragrid i did it with
Band.Columns(0).Hidden =
True
Hi Martin,
I can tell you a way to avoid this error. Create a css class:
<style type="text/css">
.hidden
{
display:none;
}
</style>
And then apply it to your column instead of setting Hidden = true:
Datacolumn1.CssClass = "hidden"
I would like to investigate this issue anyway so if it is possible for you to attach a sample in the support ticket that you created it would be very nice (and let me know if you get this error even when you set the css class.
Regards,
Lyuba
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi Lyuba, (juhu it works)if i writeDatacolumn1.Header.CssClass = "hidden"Datacolumn1.CssClass ="hidden"is important because of the header will display but not the column. if i write both , both is hidden, the complete column is hidden:)many thanks for the help>if it is possible for you to attach a sample in the support ticket that you created it would be very nice i think if you simple write .hidden=false everyone can reproduce the error. hope you can fix itthanks martin
Hello Martin,
I have built small sample based on provided details by you. I am not able to replicate the described issue. Could you have a look at it please? You can download it from the current post.
In the sample I am using your code as much as possible.
aspx markup :
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <ig:WebDataGrid ID="WebDataGrid1"
runat="server"
Height="350px"
Width="98%"
AutoGenerateColumns="false"> <Behaviors> <ig:Selection RowSelectType="Multiple"
CellClickAction="Row" Enabled="true" /> <ig:RowSelectors RowNumbering="true"
Enabled="true" /> </Behaviors> </ig:WebDataGrid> </ContentTemplate> </asp:UpdatePanel>
Code file:
if (!Page.IsPostBack) { //Add behavior this.WebDataGrid1.Behaviors.CreateBehavior<Paging>(); //Handle PageIndexChanged event this.WebDataGrid1.Behaviors.Paging.PagingClientEvents .PageIndexChanged = "WebDataGrid1_PageIndexChanged"; BoundDataField Datacolumn1 = new BoundDataField(); Datacolumn1.DataFieldName = "id"; Datacolumn1.Key = "id"; Datacolumn1.Header.Text = "id"; Datacolumn1.Hidden = true; WebDataGrid1.Columns.Add(Datacolumn1); Datacolumn1 = new BoundDataField(); Datacolumn1.DataFieldName = "Item"; Datacolumn1.Key = "Item"; Datacolumn1.Header.Text = "Item"; Datacolumn1.Hidden = false; WebDataGrid1.Columns.Add(Datacolumn1); Datacolumn1 = new BoundDataField(); Datacolumn1.DataFieldName = "Data"; Datacolumn1.Key = "Data"; Datacolumn1.Header.Text = "Data"; Datacolumn1.Hidden = false; WebDataGrid1.Columns.Add(Datacolumn1); } WebDataGrid1.DataSource = this.MakeTable(); WebDataGrid1.DataBind(); this.WebDataGrid1.Behaviors.Paging.PagerTemplate = new CustomPagerTemplate();
.PageIndexChanged = "WebDataGrid1_PageIndexChanged"; BoundDataField Datacolumn1 = new BoundDataField(); Datacolumn1.DataFieldName = "id"; Datacolumn1.Key = "id"; Datacolumn1.Header.Text = "id";
Datacolumn1.Hidden = true; WebDataGrid1.Columns.Add(Datacolumn1); Datacolumn1 = new BoundDataField(); Datacolumn1.DataFieldName = "Item"; Datacolumn1.Key = "Item"; Datacolumn1.Header.Text = "Item"; Datacolumn1.Hidden = false; WebDataGrid1.Columns.Add(Datacolumn1); Datacolumn1 = new BoundDataField(); Datacolumn1.DataFieldName = "Data"; Datacolumn1.Key = "Data"; Datacolumn1.Header.Text = "Data"; Datacolumn1.Hidden = false; WebDataGrid1.Columns.Add(Datacolumn1); } WebDataGrid1.DataSource = this.MakeTable(); WebDataGrid1.DataBind(); this.WebDataGrid1.Behaviors.Paging.PagerTemplate = new CustomPagerTemplate();
As you can see I hide the first column as you suggested.
Let me know what I am missing in this sample to get the error.
Hi,
i have the same error in WebDataGrid when i hide a column like this:
<
ig:BoundDataField DataFieldName="AufLiefPosId" DataType="System.Int32" Hidden="true" Key="PosId" Width="50px">
I use Version=11.1.20111.2020 / .net 4
Please fix this bug.
Now i use the CssClass="hidden" like above and it works fine....
The problem is solved when you remove the Runat="server" from the html head tag.
Same here! Having the "Hidden" attribute on ig:BoundDataField results in the error:
"The Controls collection cannot be modified because the control contains code blocks (i.e.: <% ... %>)."
No where in my entire Grid markup do I have code blocks. This occurs if I have the Hidden attribute on the BoundDataField AT ALL, regardless of the value given (true/false).
I'm working with NetAdvantage ASP.NET release 2011.1. Why? Because I have to.