gpt4 book ai didi

c# - 如何在 CodeBehind 的 DetailTable 中访问 FooterText (Telerik-RadGrid)?

转载 作者:行者123 更新时间:2023-11-30 17:59:24 24 4
gpt4 key购买 nike

我的 asp.net web 表单中有一个 Telerik RadGrid,如下所示:

MasterTableView
DetailTables -> GridTableView

在那个细节表中,我有一列如下:

                            <telerik:GridTableView runat="server" DataKeyNames="ID,Customer_ID,CardType_ID,OrderStatus_ID"
DataSourceID="sdsOrders" AllowFilteringByColumn="True"
AllowMultiColumnSorting="True" AllowSorting="True" ShowFooter="True" OnDataBinding="GridTableView_DataBinding">
...

<telerik:GridBoundColumn DataField="TotalPrice" DataType="System.Int32" FilterControlAltText="Filter TotalPrice column"
HeaderText="TotalPrice" SortExpression="TotalPrice"
UniqueName="TotalPrice" AllowFiltering="False" FooterText="Sum: " Aggregate="Sum">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
</telerik:GridBoundColumn>

我想更改页脚文本 (Sum) 和页脚 (Sum) 的颜色。
对于 MasterTableView 中的 DataBoundColumns,下面的代码有效:

protected void GridTableView_DataBinding(object sender, EventArgs e)
{
GridBoundColumn TotalPrice = grdCustomers.MasterTableView.GetColumnSafe("TotalPrice") as GridBoundColumn;
TotalPrice.FooterAggregateFormatString = "<span class=\"AggregateTitleColor\">Sum : </span>" + "{0:#,0 ;#,0- }";
TotalPrice.FooterStyle.ForeColor = ColorTranslator.FromHtml("blue");
}

现在如何为 DetailTable 中的 TotalPrice 重写这些代码?

提前致谢

最佳答案

我找到了答案:
首先应该在 MasterTableView 中使用 DataBinding。
并像这样重写代码:

protected void MasterTableView_DataBinding(object sender, EventArgs e)  <- Pay Attention Here
{
GridBoundColumn TotalPrice = grdCustomers.MasterTableView.DetailTables[0].GetColumnSafe("TotalPrice") as GridBoundColumn;
TotalPrice.FooterAggregateFormatString = "<span class=\"AggregateTitleColor\">Sum : </span>" + "{0:#,0 ;#,0- }";
TotalPrice.FooterStyle.ForeColor = ColorTranslator.FromHtml("blue");
}

你就完成了。

关于c# - 如何在 CodeBehind 的 DetailTable 中访问 FooterText (Telerik-RadGrid)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11234661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com