如何将RadGrid(Telerik)Sum的String.Format导入页脚?

时间:2011-07-18 13:56:31

标签: telerik footer radgrid string.format

我的radgrid列如下:

<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>  

我怎样才能将String.Format(重新格式化)与该模板列的页脚结果相加? 我想在输出中想要{0:#,0 Dollar;#,0- Dollar}之类的东西......

提前致谢

2 个答案:

答案 0 :(得分:2)

以下链接解决了我的问题:

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}";
}

答案 1 :(得分:-1)

您可以向Eval函数添加其他Format参数:

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