Reputation: 9746
While Binding data to TextBox
, I want to convert it to dd/MM/yyyy
format. In the Following Code, HolidayDate
can be in any format which comes from db.
@Html.TextBoxFor(m => m[i].HolidayDate, new { @class = "datepicker", @value = @Model[i].HolidayDate.ToString("dd/MM/yyyy") })
The date doesn't get converted to dd/MM/yyyy
. How to Convert the date in a particular format?
Upvotes: 0
Views: 221
Reputation: 3819
@Html.TextBoxFor(m => m[i].HolidayDate, "{0:dd/MM/yyyy}", new { @class = "datepicker", @value = @Model[i].HolidayDate.ToString("dd/MM/yyyy") })
Upvotes: 2