Formating Date in Auto generated column

2 posts, 0 answers
  1. shabbir mohammad
    shabbir mohammad avatar
    7 posts
    Member since:
    Jan 2010

    Posted 10 May 2011 Link to this post

    Hi

    How can I format date in auto generated column? Can someone point me to the right direction?

    Thanks In advance
    Shabbir.
  2. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 11 May 2011 Link to this post

    Hi Shabbir,

    This is fairly simple to do. Telerik provides a good server-side event called "OnAutoGeneratedColumnCreated" that you can use to update the DateFormatString for your RadTreeList. You can specify the UniqueName of the column in the method so that you are only updating the format for the items you choose. Here is an example:

    <telerik:RadTreeList ID="RadTreeList1" runat="server"
        AllowMultiItemEdit="False" Culture="(Default)" DataKeyNames="EmployeeID"
        DataSourceID="SqlDataSource1" IsItemInserted="False" AutoGenerateColumns="true" ParentDataKeyNames="ReportsTo" OnAutoGeneratedColumnCreated="RadTreeList1_OnAutoGeneratedColumnCreated">
    </telerik:RadTreeList>

    protected void RadTreeList1_OnAutoGeneratedColumnCreated(object sender, TreeListAutoGeneratedColumnCreatedEventArgs e)
    {
          
        if (e.Column.UniqueName == "BirthDate")
        {
            TreeListBoundColumn myColumn = (TreeListBoundColumn)e.Column;
      
            myColumn.DataFormatString = "{0:dd/MM/yyyy}";
        }
      
    }

    Hope this helps!
    -Gimmik
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top