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.
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.
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.
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.
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.
Then it looks to me that there is somthing wrong in your:
Data Model
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.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
18 Points
187 Posts
Why
Sep 25, 2013 02:22 AM|mr41971|LINK
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.
Participant
1284 Points
373 Posts
Re: Why
Sep 25, 2013 02:28 AM|asyed4u|LINK
hi,
u can alter the display columns for the [ foreign key ]
http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx
All-Star
101931 Points
20703 Posts
Re: Why
Sep 25, 2013 02:41 AM|MetalAsp.Net|LINK
Can you clarify your question? I, for one, have no idea what you're talking about or asking.
Member
18 Points
187 Posts
Re: Why
Sep 25, 2013 03:18 AM|mr41971|LINK
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.
All-Star
17916 Points
5681 Posts
MVP
Re: Why
Sep 25, 2013 06:34 AM|sjnaughton|LINK
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?
Always seeking an elegant solution.
Member
492 Points
200 Posts
Re: Why
Sep 25, 2013 06:51 AM|mdsajidfaizan|LINK
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";
//-------------------------------------------------------------
Member
18 Points
187 Posts
Re: Why
Sep 25, 2013 07:05 AM|mr41971|LINK
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.
All-Star
17916 Points
5681 Posts
MVP
Re: Why
Sep 25, 2013 08:38 AM|sjnaughton|LINK
Did you add DD to you Web Forms Dynamic Data project of sis you start from the Dynamic Data project template?
Always seeking an elegant solution.
Member
18 Points
187 Posts
Re: Why
Sep 25, 2013 11:32 AM|mr41971|LINK
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:
Notice the getStudentIDsByParent() function. I am logging in as Clerk which is the only role that can see or edit the Status field.
Member
18 Points
187 Posts
Re: Why
Sep 25, 2013 12:26 PM|mr41971|LINK
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.
All-Star
17916 Points
5681 Posts
MVP
Re: Why
Oct 18, 2013 05:09 AM|sjnaughton|LINK
Then it looks to me that there is somthing wrong in your:
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.
Always seeking an elegant solution.