Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
860
NullReferenceException when hiding a column
posted

Hello,

I've a WebDataGrid inside a WebDialogWindow as follows (no matter with or without the behaviours):

<ig:WebDataGrid ID="DlgFirezonesWDG" runat="server">
    <Behaviors>
        <ig:ColumnMoving></ig:ColumnMoving>
        <ig:ColumnResizing></ig:ColumnResizing>
        <ig:Filtering></ig:Filtering>
        <ig:Sorting></ig:Sorting>
        <ig:SummaryRow></ig:SummaryRow>
    </Behaviors>
</ig:WebDataGrid>

code behind:

List<area>f=area.GetList();
  //some fields: int id, string name, string number, subarea, ...
  //where subarea is of type area
AreasWDG.DataSource=f;
AreasWDG.DataKeyFields="id";
AreasWDG.DataBind();
AreasWDG.Columns[0].Hidden=true;

 

All other grid properties have default values.

Everything works fine as long as I do not try to hide a column which is what I really want to, since e. g. the subarea field is an entity object and does not need to show up.

If I try to hide a column, no matter using the index (0, 1 or whatever) or the key ("id", "subarea", ...) I get a NullReferenceException. This is because AreasWDG.Columns actually does not contain any columns. Nevertheless AreasWDG.Rows does (count=6) and AreasWDG.HasColumns is true.

Am I doing something wrong or why does this happen?

regards