0

我的 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(reformat) Sum 导致此模板列的页脚?
意思是我想要像 {0:#,0 Dollar;#,0- Dollar} 这样的输出...

提前致谢

4

2 回答 2

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}";
}
于 2011-07-18T17:04:59.573 回答
-1

您可以向 Eval 函数添加一个额外的 Format 参数:

Eval("Benefit", "{0:#,0 Dollar;#,0- Dollar}")
于 2011-07-18T15:35:37.413 回答