Format A Databound Control In A GridView
This is just a little bit that I keep forgetting for some reason. Lets say I have a gridview, and in it I want to display the date. Just the date, but I do not want to use the SQL method to format the date. You just add the format string to the binding.
Text='<%# Bind("myDate", "{0:MM/dd/yyyy}") %>'
This really would work with any kind of formatting that you needed to do. I just felt that date would make an easier example.
Posted on September 1, 2011, in Bits. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0