locked
Why RRS feed

  • Question

  • User1929428035 posted

    The List displays the Foreign Key (e.g. 1) and the Details displays the values (e.g. Active). Why? What am I missing? Is it something in the List.aspx? Please help before I am admitted to the ASSYLUM.

    Wednesday, September 25, 2013 2:22 AM

All replies

  • User1970566204 posted

    hi,

     

    u can alter the display columns for the [ foreign key ]

     

    http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx

    Wednesday, September 25, 2013 2:28 AM
  • User-1360095595 posted

    Can you clarify your question? I, for one, have no idea what you're talking about or asking.

    Wednesday, September 25, 2013 2:41 AM
  • User1929428035 posted

    This is a Dynamic Data project. I have an entity called Student, it has an attribute called StatusID which references a table called StudentStatus. In the List.aspx page the Status field shows the Foreign Key identity column. In the Details.aspx file The Status field shows the value for the Status Column:

    StudentStatus Table

    ID

    Status

    1

    Active

    2

    Suspended

    3

    Expelled

     I would like to have the value for the Status column displayed in the List.aspx page as well. I hope this clears things up.

    Wednesday, September 25, 2013 3:18 AM
  • User-330204900 posted

    Hi mr41971, this should work out of the box, have you tried creating a sample DD site based on Northwind or Adventure works to see this working?

    Wednesday, September 25, 2013 6:34 AM
  • User670679149 posted

    To call the table values, you are definately bibding the table with the controls.

    You just need to add this code while binding the data,

    For example if the control you are using is Dropdown

    //-------------------------------------------------------------

    DropDown1.DataTextField="Status";

    DropDown1.DataValueField="ID";

    //-------------------------------------------------------------

    Wednesday, September 25, 2013 6:51 AM
  • User1929428035 posted

    Steve I did a small DD project with just the Student table and the StudentStatus table and it worked perfectly which suggests to me that some piece of code is missing from my project somewhere, I however don't have a clue. I even tried to copy from the small DD project to my larger project into the Model.Designer.cs file with no success. I suspect I have to do a closer inspection of this file. 

    Wednesday, September 25, 2013 7:05 AM
  • User-330204900 posted

    Did you add DD to you Web Forms Dynamic Data project of sis you start from the Dynamic Data project template?

    Wednesday, September 25, 2013 8:38 AM
  • User1929428035 posted

    I started the project from scratch as a DD project. I made modification to the DomainService.cs file by adding Data Annotations and I also added some functions to allow me to present the data as the users wanted to see it. For example:

    [RequiresAuthentication]
    		[RequiresRole("Clerk", "Teacher", "Principal", "Parent")]
    		public IQueryable<Student> GetStudents()
    		{
    			if (this.ServiceContext.User.IsInRole("Parent"))
    			{
    				if (this.ServiceContext.User.IsInRole("Parent"))
    				{
    					List<int> intListofStudentIDs = new List<int>();
    					intListofStudentIDs = getStudentIDsByParent(getParentID());
    
    					return this.ObjectContext.Students.Where(s => intListofStudentIDs.Any(i => i == s.ID)).OrderBy(s => s.ID);
    				}
    
    			}
    			return this.ObjectContext.Students.OrderBy(s => s.ID);
    		}

    Notice the getStudentIDsByParent() function. I am logging in as Clerk which is the only role that can see or edit the Status field.

    Wednesday, September 25, 2013 11:32 AM
  • User1929428035 posted

    One thing I forgot to mention was that I added the StudentStatus table and the StatusID field in the Student table a few months after working on my project. I updated the model from the database and hoped that would integrate my addition neatly into my project.

    Wednesday, September 25, 2013 12:26 PM
  • User-330204900 posted

    Then it looks to me that there is somthing wrong in your:

    1. Data Model
    2. Domain Service

    Not sure what the issue could be, I have to update my data models regularly with changes etc and never have any issues but then I don't use Domain Service you may need to recreate you Domain Service and then add your modification to the new DS.

    Friday, October 18, 2013 5:09 AM