This is a migrated thread and some comments may be shown as answers.

Formating Date in Auto generated column

1 Answer 38 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
shabbir mohammad
Top achievements
Rank 1
shabbir mohammad asked on 10 May 2011, 03:26 PM
Hi

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

Thanks In advance
Shabbir.

1 Answer, 1 is accepted

Sort by
0
Gimmik
Top achievements
Rank 1
answered on 12 May 2011, 12:23 AM
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
Tags
TreeList
Asked by
shabbir mohammad
Top achievements
Rank 1
Answers by
Gimmik
Top achievements
Rank 1
Share this question
or