Please Help:
I want my WEbDataGrid to cell to display Time in HH:mm, thus i code the following:
<Behaviors> <igGrid:Activation Enabled="true" /> <igGrid:EditingCore BatchUpdating="true"> <Behaviors> <igGrid:CellEditing Enabled="true" EditModeActions-EnableOnKeyPress="true"> <ColumnSettings> <igGrid:EditingColumnSetting ColumnKey="EmployeeId" ReadOnly="true" /> <igGrid:EditingColumnSetting ColumnKey="Employee" ReadOnly="true" /> <igGrid:EditingColumnSetting ColumnKey="EmployeeType" ReadOnly="true" /> <igGrid:EditingColumnSetting ColumnKey="Designation" ReadOnly="true" /> <igGrid:EditingColumnSetting ColumnKey="WorkHour" ReadOnly="true" /> <igGrid:EditingColumnSetting ColumnKey="Time1" EditorID="WebDataGrid1_DateTimeEditorProvider1" /> </ColumnSettings>
<EditModeActions EnableOnKeyPress="True"></EditModeActions> </igGrid:CellEditing> </Behaviors> </igGrid:EditingCore> </Behaviors> <EditorProviders> <igGrid:DateTimeEditorProvider id="WebDataGrid1_DateTimeEditorProvider1"> <EditorControl DisplayModeFormat="HH:mm" EditModeFormat="HH:mm"> </EditorControl> </igGrid:DateTimeEditorProvider> </EditorProviders>
But my Grid Cell still display the DATE only. I had try to change the DisplayModeFormat="t", as it display DATE only as well.
Can anyone please enlighten me?
This is my dataSet:
<asp:SqlDataSource ID="dsPTStaffShiftTime" runat="server" ConnectionString="<%$ ConnectionStrings:GlobalDataWareHouseConnectionString %>" SelectCommand="SELECT CAST('2011-06-30 01:00:00' AS DateTime) AS Time1"></asp:SqlDataSource>
Thank you very much.
Regards,
Say Chao
Hello Say Chao,
Thanks for sharing your solution with the community.
If you have any other quesitions, please do not hesitate to ask.
Hi Nikolay,
THank you very much for your prompt reply.
I did some research too and my solution is quite similarto your:
<Columns> <igGrid:BoundDataField DataFieldName="Time1" Key="Time1" DataType="System.DateTime" DataFormatString="{0:HH:mm}" Width="35px" > <Header Text="Sat" /> </igGrid:BoundDataField> <igGrid:BoundDataField DataFieldName="Time11" Key="Time11" DataType="System.DateTime" DataFormatString="{0:HH:mm}" Width="35px" > </igGrid:BoundDataField> </Columns>
<Behaviors> <igGrid:Activation Enabled="true" /> <igGrid:EditingCore BatchUpdating="true"> <Behaviors> <igGrid:CellEditing Enabled="true" EditModeActions-EnableOnKeyPress="true"> <ColumnSettings> <igGrid:EditingColumnSetting ColumnKey="Time1" EditorID="TimeEditorProvider" /> <igGrid:EditingColumnSetting ColumnKey="Time11" EditorID="TimeEditorProvider" /> </ColumnSettings><EditModeActions EnableOnKeyPress="True"></EditModeActions> </igGrid:CellEditing> </Behaviors> </igGrid:EditingCore> </Behaviors> <EditorProviders> <igGrid:DateTimeEditorProvider id="TimeEditorProvider"> <EditorControl EditModeFormat="HH:mm" DisplayModeFormat="{0:HH:mm}"> </EditorControl> </igGrid:DateTimeEditorProvider> </EditorProviders>
<asp:SqlDataSource ID="dsPTStaffShiftTime" runat="server" ConnectionString="<%$ ConnectionStrings:GlobalDataWareHouseConnectionString %>" SelectCommand="SELECT CAST('2012-09-01 13:00' AS DateTime) AS Time1,CAST('2012-09-01 16:00' AS DateTime) AS Time11"></asp:SqlDataSource>
{0:t} give time display in 12 Hour format
{0:HH:mm} give time display in 24hour format
Hi Say Chao,
You should set the DataFormatString property of the column containing the dates, for example:
<ig:BoundDataField DataFieldName="OrderDate" Key="OrderDate" DataFormatString="{0:t}"> <Header Text="OrderDate" /></ig:BoundDataField>
More information about DataFormatString can be found here - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx.
If you have any questions please feel free to contact me.