Hello,
We are using the following column definition for a button column that should display a DateTime:
The problem is that it is standard in our app to display just the date if the time is "12:00 am", as this usually indicates that the exact time was not entered. Therefore, I need to conditionally use "{0:d}" for my format string instead of "{0:g}" when StartDate.TimeOfDay.Ticks=0.
We have a server-side function with the following format that we usually use for this logic:
In the past, we've either called the function in the ItemDataBound event or used a GridTemplateColumn with a LinkButton to call the function:
My question is whether there is something I can do in the GridButtonColumn definition to create this complex formatting logic, or if I have to use one of those two options. I tried using the GridButtonColumn "Text" field but got an error when I tried to load the page:
Databinding expressions are only supported on objects that have a DataBinding event. Telerik.Web.UI.GridButtonColumn does not have a DataBinding event.
--Christina
We are using the following column definition for a button column that should display a DateTime:
<
telerik:GridButtonColumn
UniqueName
=
"STARTDATE"
ButtonType
=
"LinkButton"
DataTextField
=
"STARTDATE"
DataTextFormatString
=
"{0:g}"
HeaderText
=
"[START DATE]"
CommandName
=
"GoToItem"
/>
The problem is that it is standard in our app to display just the date if the time is "12:00 am", as this usually indicates that the exact time was not entered. Therefore, I need to conditionally use "{0:d}" for my format string instead of "{0:g}" when StartDate.TimeOfDay.Ticks=0.
We have a server-side function with the following format that we usually use for this logic:
public
static
string
GetShortDateTimeString(DateTime? aDateTime)
In the past, we've either called the function in the ItemDataBound event or used a GridTemplateColumn with a LinkButton to call the function:
<
telerik:GridTemplateColumn
HeaderText
=
"[START DATE]"
DataField
=
"STARTDATE"
UniqueName
=
"STARTDATE"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"lnkSTARTDATE"
runat
=
"server"
Text='<%#GetShortDateTimeString((DateTime?)Eval("STARTDATE"))%>'
OnCommand="lnkViewGrid_Command" CommandArgument='<%# Eval("OID").ToString() %>'/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
My question is whether there is something I can do in the GridButtonColumn definition to create this complex formatting logic, or if I have to use one of those two options. I tried using the GridButtonColumn "Text" field but got an error when I tried to load the page:
Databinding expressions are only supported on objects that have a DataBinding event. Telerik.Web.UI.GridButtonColumn does not have a DataBinding event.
--Christina