Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / How to Display Date Time Column in WebDataGrid

How to Display Date Time Column in WebDataGrid

New Discussion
Suday Ghosh
Suday Ghosh asked on Oct 14, 2013 1:53 PM

Dear

How to display Date Time Column in WebDataGrid in Infragistics 12.1. Used AutoGenerateColumns=”true” and DataSource is DataTable. Shown only date like ’12/26/2012′ but need to show like ’12/26/2012 12:00:00 PM’ in column’s cell. Please give solution as early as possible.

Regards

Suday

Sign In to post a reply

Replies

  • 0
    Vasya Kacheshmarova
    Vasya Kacheshmarova answered on Feb 11, 2013 8:51 AM

    Hello Sunday Ghosh,

    Columns collection contains only column objects that were added by hand in either aspx or in the code behind file. The autogenerate columns are for the display purpose only, they cannot be accessed or modified.

    WebDataGrid works with items insetead of columns. What I can suggest for achieveing your requirement is handling InitializeRow event and set formatting for your DateTime column as such:

    
    

     

    protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)

        {

           if (e.Row.Index == 0)

            {

               var field = e.Row.Items[1].Column as BoundDataField;

                field.DataFormatString ="{0:g}";

            }

        }

    Please keep in mind that you have to have at least one Row initialized in the grid in order to fire the InitializeRow event.

    Some further reference about DataFormatString Property may be found at:

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx

    Feel free to contact me if you have any further questions .

     

     

     

    • 0
      Vasya Kacheshmarova
      Vasya Kacheshmarova answered on Feb 14, 2013 6:45 AM

      Hello Sunday Ghosh,

      If you still have any concerns or questions I will be glad to help. Do not hesitate to contact me if you need any further support.

  • 0
    Kimberly
    Kimberly answered on Feb 21, 2013 6:13 PM

    You can also define in the markup within the datagrid like such with the DataFormatString defined:

    <ig:BoundDataField DataFieldName="POST_DATE" Key="POST_DATE" DataFormatString="{0:MM/dd/yyyy h:mm:sstt}">

    <Header Text="Post Date/Time" />

    </ig:BoundDataField>

    • 0
      Prieti Bondre
      Prieti Bondre answered on Oct 10, 2013 10:51 AM

      In 13.1 version controls only below works : it needs to be DataFormatString="{0:G}"

      <ig:BoundDataField DataFieldName="end_dt" Key="end_dt" Header-Text="End Date" Width="145px" VisibleIndex="7" DataType="System.String" DataFormatString="{0:G}"/>

       

      • 0
        Vasya Kacheshmarova
        Vasya Kacheshmarova answered on Oct 14, 2013 1:53 PM

        Hello,

        Thank you for your feedback and for sharing this with us. We believe that the other community members could benefit from such threads.

        Please feel free to let me know if a question about our tool set comes up on your mind.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Suday Ghosh
Favorites
0
Replies
5
Created On
Oct 14, 2013
Last Post
12 years, 10 months ago

Suggested Discussions

Created by

Created on

Oct 14, 2013 1:53 PM

Last activity on

Feb 23, 2026 4:39 PM