The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I have a databound grid and the data source has a DateTime column. By default the grid only displays the date and not the time (and the date selection control). I tried to set the format of the column in the model; however, that had no effect. What do I need to do?
m_gridData.DataSource = m_dsData.Tables[0].DefaultView;
m_gridData.Model.ColStyles["DateStamp"].CellValueType = typeof(DateTime);
m_gridData.Model.ColStyles["DateStamp"].Format = "HH:mm MM/dd/yy";
Is the code snipit... originally I didn''t have the CellValueType call in there but thought maybe that explicitly setting the type might help; however, it didn''t.
Thank you in advance,
Jon
ADAdministrator Syncfusion Team August 27, 2004 03:05 PM UTC
To set style properties on a column in a GridDataBoundGrid, you use the GridBoundColumn.StyleInfo object instead of the ColStyle object used for GridControl.
So, try
GridStyleInfo style = m_gridData.Binder.InternalColumns["DataStamp"].StyleInfo;
style.CellValueType = typeof(DateTime);
style.Format = "HH:mm MM/dd/yy";
if you have not explicitly added GridBoundColumns to your grid. If you have added GridBoundCOlumns, use:
GridStyleInfo style = m_gridData.GridBoundColumns["DataStamp"].StyleInfo;
style.CellValueType = typeof(DateTime);
style.Format = "HH:mm MM/dd/yy";