3

我的 asp.net 网络表单中有一个 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>

我想更改页脚文本(总和)和页脚中的(总和)的颜色。
对于 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 重写这些代码?

提前致谢

4

2 回答 2

1

我找到了答案:
首先应该在 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");
}

你就完成了。

于 2012-06-27T21:54:30.050 回答
0

查看RAD Grid控件中的总计文档。我知道您已经知道如何显示总计,但是那里有一大段 C# 和 ASP 代码显示使用 FooterStyle 属性更改页脚颜色。

于 2012-06-27T20:59:24.030 回答