Field not showing in gridview asp.net 3.5
Here is the situation, i have two tables tblProduct and tblCategory, what i am trying to do is populate a gridview, i have LinqDataSource binded to the grid and the correct association made inside the .dbml (tblProduct.CategoryID to tblCategory.ID).
To show the fields from tblCategory instead of the tblProduct.CategoryID in the GridView i am using :
<ItemTemplate>
<asp:Label ID="Label5" 开发者_如何学JAVArunat="server" Text='<%# Eval("tblCategory.Name") %>'>
</asp:Label>
</ItemTemplate>
This works fine inside the VS2008 debugger, but once its published to the server (2003 + IIS6.0) the column that belong to tblCategory simply don't show, instead of having the category name (tblCategory.Name) displayed like it does inside the debugger it is blank, no errors simply wont show.
Can anyone shed some light in this?
I mocked up a the tables and .aspx page you described and am not having any trouble. My intuition says that this isn't a code problem, but a deployment problem. I'm wondering:
- Are you set up with a "web site" project or a "web application"?
- If you're using a "web site" project, which options do you have selected on deploy (ie: "Allow this precompiled site to be updateable", "Use fixed naming and single page assemblies", etc.)
- Have you tried deploying to a new, clean area on your web server instead of overtop of a previous release?
What methods have you used to ensure the the version you are looking at on the server is the same that you have on your development machine?
Perhaps try adding a comment to the bottom of your development page, then redeploying. If you can't see the comment on the published version you know something else is wrong with your deployment.
I could not after all figure out exactly what was going on, but by enabling the options "Enable Insert", "Enable Update" and "Enable Delete" on the DataSource the problem was solved and the columns started showing properly on the GridView even though i do not use any of those functions, the GridView is used only to display data.
I have no clue why would one thing be connected to the other, my best guess is that perhaps to use TemplateFields you must have those options enabled.
I any event, it is working now, thanks to the people who have tried to help.
精彩评论