开发者

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

开发者 https://www.devze.com 2023-03-21 05:51 出处:网络
my radgrid column like below : <telerik:GridTemplateColumn FilterControlAltText=\"Filter TemplateColumn_Benefit\" DataField=\"Benefit\"

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 adva开发者_如何学Pythonnce


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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消