I have a table [Users] with the following columns:
INT SmallDateTime Bit Bit
[UserId], [BirthDate], [Gender], [Active]
Gender and Active are Bit that hold either 0 or 1.
I am displaying this data in a table on my View.
-
For the Gender I want to display
‘Male’ or ‘Female’, how and where do
I manipulate the 1’s and 0’s? Is it done in the repository where I fetch the data or in the View? -
For the Active column I want to show
a checkBox that will AutoPostBack on selection change
and update the Active filed in the
Database. How is this done without
Ajax or jQuery?
For Question #1:
Use a DisplayTemplate. In View/Shared create a folder named DisplayTemplates. Then Add a partial View to this folder named Gender.ascx. Make sure it is not strongly typed.
the markup in this file will look like this:
Then in your Model you decorate the Gender property with a UIHint thusly:
In your View you make it use this template by using DisplayFor
If you cannot use the UIHint you can explicity name your template in DisplayFor