ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Display field names from DataAnnotation in column headers
Title:
B
I
{code}
?
Hello, can I somehow display field names from DataAnnotation in column headers? For example - field: [Display(Name = "Route ID")] public long route_id {get; set;} column binding: new Column { Bind = "route_id", Header = " " } Thank You for really awesome library.
Save Changes
Cancel
Vladimir Kerzhentsev
asked at 17 Jun 2019
Answers
B
I
{code}
?
you set the column header like this: `new Column { Header = "abc" ...`, so if you can get the value you want in the view, you'll be able to use in the header, so what you need to find out is how to get the Name property of display attribute in C#. maybe this will help: https://stackoverflow.com/questions/5015830/get-the-value-of-displayname-attribute perhaps you can create a `Column` extension method that will set both `Bind` and `Header`
Save Changes
Cancel
Omu
answered at 17 Jun 2019
Thank You! That should work.
at 20 Jun 2019
Vladimir Kerzhentsev
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK