ViewValue proprty of field in EditPage

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
usr338
User
Posts: 3

ViewValue proprty of field in EditPage

Post by usr338 »

I have a field in table with type of smallDate.
I want to show this field in special format every where that field is diplayed (like list view , view page and in edit page)
I wrote following code:

public void Row_Rendered() {
if (StartDate.DbValue != null && StartDate.DbValue != DBNull.Value)
StartDate.ViewValue = ((DateTime)StartDate.DbValue).ToMyDateFormat();
}

but when i edit field, I see "startdate" field with default format! whats wrong ?
thanks.


vincenthung
User
Posts: 88

Post by vincenthung »

In edit page, you should format the Edit Value

For example:
<Field>.EditValue = ew_FormatDateTime(<Field>.CurrentValue, 7);


usr338
User
Posts: 3

Post by usr338 »

First of all tanks for response, but i have to mention something else.
If i change the EditValue field , the DBValue of field will change too. i want to show my formatted date in Edit page , not changing the original value. by formating the value(with my formatting rule) and assigning it to Fields EditValue, with some value i get date error because it is not valid date.


Webmaster
User
Posts: 9427

Post by Webmaster »

To use your own format instead of the built in date format:

  • Change [View Tag] -> [Format] from "Date/Time" to "None"
  • Use the Row_Rendered server event to format the field in your custom format

Post Reply