On the initial load of this page my template column, in an asp data grid, displays fine. When I click any controls that force a post back the data grid reloads with the template column hidden. There is no visible attribute being set in the html. There is no code changing the visible property of the column in the code-behind.
I tried to hard-code the column's visibility to true and the property reads true in the code-behind but the column still gets hidden.
When trying to hide/show other columns in the data grid I'm unable to change them via the code-behind.
Any ideas on what is causing this column to auto-hide or why I can't effectively change the visible property in the code-behind or html?
<asp:DataGrid ID="dg" runat="server" AllowSorting="True" AutoGenerateColumns="False" CssClass="datagridPWQ">
<Columns>
<asp:BoundColumn DataField="ID" HeaderText="ID" />
<asp:TemplateColumn HeaderText="Add" >
<ItemTemplate>
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="Add"
CssClass="buttonQ" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID")%>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
Side note: I have thought about using a ButtonColumn instead but I would still like to know why this doesn't work. I remember seeing a similar error months ago but I don't remember how it was solved.