Last post Dec 24, 2010 08:22 AM by sjnaughton
Dec 20, 2010 07:23 AM|JohanNL|LINK
ASP.NET Dynamic Data uses the columnnames from a table from SQL default.
How can I change these columnnames?
Dec 20, 2010 07:46 AM|ignatandrei|LINK
Dec 20, 2010 07:49 AM|adeelehsan|LINK
See the following link:
Dec 20, 2010 12:51 PM|sjnaughton|LINK
Hi JohanNL, you would just use the DisplayName attribute in your metadata.
Dynamic Data 4
Dec 21, 2010 02:11 AM|adeelehsan|LINK
sjnaughton is right. You need to add the DisplayName attribute in metadata of your Linq to SQL classes file (.designer.cs) like the following:
Assuming that I have CustomerID field, so the code goes like the following:
[Column(Storage="_CustomerID", DbType="NChar(5) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
[DisplayName("ID of Customer")]
public string CustomerID
if ((this._CustomerID != value))
this._CustomerID = value;
Dec 21, 2010 03:16 AM|JohanNL|LINK
So simple. Googled for hours. Had it almost, but forgot the getter and setter.
Works perfect now.
Dec 21, 2010 05:01 AM|JohanNL|LINK
Got the default columns working. But now I have the Primary-Foreign relation columns left.
DD doesn't show the ID columns, but picks the first regular column.
* How can I change the column DD selects automatically?
Dec 22, 2010 07:14 AM|sjnaughton|LINK
Hi JohanNL, if I undestand what you want, I think you can use the DisplayColumn attribute it take three parameters and you set it on the Foreign key table
[DisplayColumn("ColumnToDisplay", "ColumnToSortOn", true if you want it descending)]
or you can use this article from Rick Anderson Improving the FK field display: Showing two fields in Foreign
Dec 24, 2010 06:45 AM|JohanNL|LINK
The article is great.
You have to put the attribute on the table where the primary key is.
Dec 24, 2010 08:22 AM|sjnaughton|LINK
yes JohanNL, you do Rick did a very good article there too it's been very useful to me [:)] Note if you want sorting you still need the Attribute as well as Rick's technique.