SilverLight
SilverLight

Reputation: 20468

how String.Format of RadGrid(Telerik) Sum result in footer?

my radgrid column like below :

<telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn_Benefit" DataField="Benefit"
                    HeaderText="Benefit" UniqueName="TemplateColumn_Benefit" FilterImageToolTip="Filter">
                    <ItemTemplate>
                        <asp:Label ID="lblBenefitInsideGrd" runat="server" Font-Size="11px" Text='<%# (bool)Convert.IsDBNull(Eval("Benefit")) ? "<span class=\"lblInsideGrd\">Empty</span>" : String.Format("{0:#,0 Dollar;#,0- Dollar}", Eval("Benefit")) %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="60px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="60px" />
                </telerik:GridTemplateColumn>  

how can i String.Format(reformat) Sum result in footer for this template column ?
mean i want something like {0:#,0 Dollar;#,0- Dollar} in output...

thanks in advance

Upvotes: 0

Views: 6997

Answers (2)

SilverLight
SilverLight

Reputation: 20468

the below link solved my problem :

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/aggregates/defaultcs.aspx

/// <summary>
/// The MasterTableView.DataBinding event is used to preserve the applied formatting to
/// data values in the column aggregate and still be able to add the name of the currently
/// selected aggregate function.
/// </summary>
protected void MasterTableView_DataBinding(object sender, EventArgs e)
{
    GridNumericColumn unitPriceCol = RadGrid1.MasterTableView.GetColumnSafe("UnitPrice") as GridNumericColumn;
    unitPriceCol.FooterAggregateFormatString = unitPriceCol.Aggregate.ToString() + ": {0:C}";
}

Upvotes: 1

devin
devin

Reputation: 194

You can add an additional Format argument to the Eval function:

Eval("Benefit", "{0:#,0 Dollar;#,0- Dollar}")

Upvotes: -1

Related Questions