table field names vs. display names

B

Bob

When displaying data from the database, very often the field names are not
suitable so custom headings have to be created, For example, the column
storing zip code may be named zip, but when displayed, it may need to be
displayed as "Zip", "Postal Code", "Zip/Postal Code" etc. DataGrid/DataList
allow headings to be created but it's usually hardcoded. And the hardcoding
is even worse if a row of data is to be displayed in columns, e.g. user
profile data is usually stored as rows but when editing one user, it's
usually displayed as a two column table, the first column with headings
(First Name, Last Name, etc), and the second column input boxes.

I would very much like to avoid hardcoding the field name to display words
mapping at all, and wonder how it's usually done. Where do people maintain
such a mapping and how?

Thanks for any suggestions.
Bob
 
L

Lucas Tam

I would very much like to avoid hardcoding the field name to display
words mapping at all, and wonder how it's usually done. Where do
people maintain such a mapping and how?

Have a table call ColumnMappings. In the table you would have:

TableName
ColumnNumber (or Name)
DisplayName

When you output the data, select from the ColumnMappings Table to get the
display name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top