Click here to Skip to main content
15,906,106 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a GridView in Webform application. I have defined all the columns in the aspx page.
In one scenario my logic is not returning one column that is defined in aspx page as following:

<asp:TemplateField HeaderText="Inventory Status">
  <ItemTemplate>
   <asp:Label ID="lblInventoryStatus"
  CssClass="rptheadingwithBottom" runat="server" Text='<%# Bind("Inventory Status")%>'>
   </asp:Label>
  </ItemTemplate>
</asp:TemplateField>


The
Inventory Status
Column is not returning thus generating error in code. What i want to know is there any way other than
AutoGenerateColumns= true
to display this column or hide this column based on logic.

What I have tried:

Nothing Unable to find the solution
Posted
Updated 15-Aug-17 21:15pm
Comments
CHill60 15-Aug-17 7:43am    
Try having column names without spaces in, or try surrounding Inventory Status with square brackets (will not work prior to VS2010)

try adding a class to the column and add the display style to show/hide the column
 
Share this answer
 
Hi..,

Set AutoGenerateColumns= false
Column Name use without space InventoryStatus

You can try this way

<asp:Label ID="lblInventoryStatus"
CssClass="rptheadingwithBottom" runat="server" Text='<%#Eval("InventoryStatus") %>'>
</asp:Label>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900