Last post Feb 13, 2012 12:06 PM by Samthapar
Feb 03, 2012 05:38 PM|Samthapar|LINK
In my project there are two tables (Users & Roles). I'm using Dynamic Data (Code-Behing VB.Net). In my existing code when i click on the Insert Link it takes me to the page which has got two DropDownLists (Roles & Users). In my users DropDownList i could
just see the Forename of the Users. I also want Forename & Surname together in the same control. I tried most of the things, but nothing happened. Can anyone please help me out in solving the problem with some information about it.??
Feb 03, 2012 05:47 PM|sivakumar321|LINK
Post your problem code ,screen shots.
use concatenation(+) funtion in sql to combine to fields of the table and bind it to the dropdown.
Feb 04, 2012 09:27 AM|sjnaughton|LINK
You can override the ToString method of the entity to do that see Rick Andersons article here
Improving the FK field display: Showing two fields in Foreign Key columns
Feb 06, 2012 05:45 AM|Samthapar|LINK
Thanks for the reply. As I'm new to Dynamic Data, So, I am not been able to figure it out, where to make the changes and do i need to add any new aspx page in the project. I'm sending you the code & the screen shots. Please Help....
So, the above are the screen shots. Now, where should i change and what should i change??
Feb 06, 2012 05:48 AM|Samthapar|LINK
I have used ADO.NET Entity Data Model which has generated an .EDMX file automatically, therefore I didn't write any SQL. This scaffolding automatically resolves PK/FK relationships and substitutes the IDs/PK of parent table with another more descriptive
column. In my case, when I view the Orders (child) table, it shows me the FirstName field from Customers (parent) table instead of the PK which is CustomerID.
Now I would like to see the full name of a customer instead of the FirstName. I have seen some posts which describe how to do it using a Literal control but I want to know how do we populate dropdown lists. In ForeignKey_Edit.acsx.cs, a method PopulateListControl()
is called on Page Load event which is probably doing all the stuff I am after but I cant find a way to override it. Or may be there is another way to do this.
Please help me
Feb 07, 2012 12:41 PM|sjnaughton|LINK
Hi Samthapar, the solution I mentioned above is the only one that works for DD with ADO.Net Entity Framework. you will need to create your buddy classes for Metadata and then override the ToString method of the Entity to get the desired result.
Feb 08, 2012 05:14 AM|Samthapar|LINK
Thanks for the reply. I have tried that one. But the issue here is i have to fetch the Surname from the different table and I'm not been able to find out the possible solutions for the same. If you have any clue please let me know, it would be a great help.
Feb 08, 2012 05:27 AM|sjnaughton|LINK
I would look at using a computed column and a scaler valued function to retrive the value in the DB.
Feb 13, 2012 12:06 PM|Samthapar|LINK
I have two tables User & UsersInRoles
User Table has got:
UsersInRoles has got:
(Just 3 Columns)
I have two dropdowns
Role : Readonly/Admin/Edit
& the path is /UsersInRoles/Insert.aspx
Now, I want to display the Forename + Surname in User DropDown. I added a class file with the name UsersInRole.vb and the code is below:
Partial Public Class UsersInRole
Public ReadOnly Property FullUserName() As String
Dim x As String = Me.User.Forename & " " & Me.User.Surname
<DisplayName("User in Roles")> _
Public Class UsersInRoleMetaData
'Public FullUserName As Object
I tried most the things you mentioned, but when i try to access the Surname, it says "Property not found in UsersInRoles".
Can you please tell me, where am I doing the wrong. I mean I am really confused about it, where to make the changes and which new file should I add. Can you please send me some solution with structure. It would be a great help.
Looking forward to hear from you soon.