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

How would that be possible to set the Expression value at runtime?

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pooya
Top achievements
Rank 1
Pooya asked on 04 Oct 2011, 11:52 AM
I have a RadGrid with 1 detail table which is defined declaratively and I'm using 2 SqlDataSources; one for the master table and the second for the detail table.

My detail table has a GridCalculatedColumn:

 <telerik:GridCalculatedColumn HeaderText="Duration (calculated)" DataType="System.String"
                            DataFields="Duration" UniqueName="Duration-custom" Expression="1">
                        </telerik:GridCalculatedColumn>

How would that be possible to set the Expression value at runtime?

I'd like to set this value to the expression:

TimeSpan.FromSeconds({0})

which returns data in this format in C#: d.hh:mm:ss e.g. 1.10:10:10

Thanks,

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 06 Oct 2011, 02:41 PM
Hi Pooya,

You could set the Expression property on Page_Load:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    (RadGrid1.MasterTableView.GetColumnSafe("CalculatedCol") as GridCalculatedColumn).Expression = "{0}*{1}";
}

If the column is inside the details table, you would need to access the nested table as shown in this helps article:
http://www.telerik.com/help/aspnet-ajax/grid-traversing-detail-tables-items-in-grid.html

All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Pooya
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or