Skip to main content
Tab

GridViewDataTimeEditColumn Class

A data column that displays DateTime values.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public class GridViewDataTimeEditColumn :
    GridViewEditDataColumn

Remarks

GridViewDataTimeEditColumn objects represent data columns used to display and edit time portions of data taken from DateTime data fields. The column editor’s settings can be accessed and customized using the GridViewDataTimeEditColumn.PropertiesTimeEdit property.

To learn more, see Data Columns.

Display a TimeSpan value in a column

To display a TimeSpan values in a column, hide the original column bound to the DateTime field and use an extra Unbound Column to perform the conversion between TimeSpan and DateTime types.

<dx:ASPxGridView ID="ASPxGridView1" runat="server"  
    OnRowInserting="ASPxGridView1_RowInserting"  
    OnRowUpdating="ASPxGridView1_RowUpdating"  
    OnCustomUnboundColumnData="ASPxGridView1_CustomUnboundColumnData"  
    ...  
<Columns>  
    <dx:GridViewDataTimeEditColumn FieldName="Time" Visible="false" />  
    <dx:GridViewDataTimeEditColumn FieldName="UnboundTime" Caption="Time" UnboundType="DateTime">  
        <PropertiesTimeEdit DisplayFormatString="HH:mm:ss" EditFormat="Custom" EditFormatString="HH:mm:ss" />  
    </dx:GridViewDataTimeEditColumn>  
...  
// Display value
protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e) {  
    if (e.Column.FieldName == "UnboundTime") {  
        e.Value = DateTime.MinValue.Add((TimeSpan)e.GetListSourceFieldValue("Time"));  
    }  
}  
// Get value
protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) {  
    DateTime date = (DateTime)e.NewValues["UnboundTime"];  
    e.NewValues["Time"] = date.TimeOfDay;  
}  
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {  
    DateTime date = (DateTime)e.NewValues["UnboundTime"];  
    e.NewValues["Time"] = date.TimeOfDay;  
}  
See Also