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

发布于 2024-11-25 06:01:43 字数 1018 浏览 5 评论 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} 的内容...

提前致谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴意少年 2024-12-02 06:01:43

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

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

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}";
}
表情可笑 2024-12-02 06:01:43

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

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

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

Eval("Benefit", "{0:#,0 Dollar;#,0- Dollar}")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文