Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 06, 2012 07:29 PM by pallone
Feb 03, 2012 03:07 PM|LINK
I created an ASP.NET Dynamic Data Web Application
I would like to customise the List page to display only some fields in the grid view for a particular table. That is what I have done:
1 - Created a folder under CustomPages folder called tblUsers (my table name is tblUser and the entity set name is tblUsers)
2 - I copied the List.aspx from the PageTemplates folder into the CustomPages/tblUsers I created.
However, the application does not compile any more. I think there is a conflict with the names in the file I copied. I get a lot of errors.
Please can someone shed some light on how to fix this? I saw a talk by David where he justed copied the List.aspx to the new folder and everything just worked. Why this is not working for me?
Error 1 The type 'MarsUsersAdmin.List' already contains a definition for 'table' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs 14 29 MarsUsersAdmin
Error 2 Type 'MarsUsersAdmin.List' already defines a member called 'Page_Init' with the same parameter types C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.cs 16 24 MarsUsersAdmin
Error 3 The type 'MarsUsersAdmin.List' already contains a definition for 'headContent' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs 18 61 MarsUsersAdmin
Error 12 The type 'MarsUsersAdmin.List' already contains a definition for 'GridView1' C:\dev\MarsUsersAdmin\MarsUsersAdmin\DynamicData\CustomPages\tblUsers\List.aspx.designer.cs 34 62 MarsUsersAdmin
Feb 03, 2012 03:20 PM|LINK
Simple solution Pallone, you need to change the namespace on the page you copied what I usually do is:
in the .aspx page
<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="Northwind.TableName.List" %>
in the .cs file
hope that helps, this is normal in any Web Application project and does not happen in Website project.
Feb 03, 2012 04:47 PM|LINK
This is strange because I have a demo where this is working and the namespace is the same in the page I copied.
I will try to change the name and see what happens. By the way, do I have to use the table name or entity set name for the folder?
Feb 03, 2012 04:59 PM|LINK
I have changed the namespace as you suggested but now I get a 404 error. This is how I changed it:
tblUser = table name
tblUsers = Entity Set name
@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="MarsUsersAdmin.tblUser.List"
public partial class List : System.Web.UI.Page
What have I done wrong?
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /DynamicData/CustomPages/tblUsers/List.aspx
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Feb 03, 2012 05:13 PM|LINK
the folder name should also be the plural name of the table the namespace dose not matter, it just has to be unique.
Feb 03, 2012 05:30 PM|LINK
This is exactly what I did but it is still not working.
Feb 04, 2012 06:24 AM|LINK
The problem is that you're trying to request the custom page directly (/DynamicData/CustomPages/tblUsers/List.aspx). Instead, the idea of Custom Pages is that you keep on making the same request as before you had the custom page, but you'll end up having
it override the Page Template.
e.g. here you probably want to request /tblUsers/List.aspx
Feb 04, 2012 07:34 PM|LINK
I have not changed anytying in the application. I just followed your MIX08 talk and copied the List.aspx page to the CustomPages/tblUsers/List.aspx.
However, after I do that the application does not build. I get a lot of namespaces conflict which you did not get in the talk.
Could you please shed some light why this is happening to me?
Feb 04, 2012 07:57 PM|LINK
Claudio, I think we're talking about two unrelated things here. :)
Your initial issue was caused by keeping the same namespace as Steve mentioned. I assumed this was resolved.
My response was to the follow up 404 error.
Feb 04, 2012 11:56 PM|LINK
yes, I changed the namespace as Steve mentioned and the application builds ok but then I get the 404 error as the file did not exists.
I do not know how to fix this. Why DD is not able to find the new folder and file under the CustomPages folder?
But in your MIX08 talk you did not have to change the namespace after copying the List.aspx file under the new folder and it just worked.
I also have some sample code from another source and I have checked the List.aspx that he copied under the CustomPages/Companies folder and it works fine. He did not have to change the namespace at all.
I was wondering if this caused because I am using a Web application and his demo uses a Web Site. Also I put my EF model under a folder called DAL.