【问题标题】:How Access FooterText (Telerik-RadGrid) In A DetailTable In CodeBehind?如何在 CodeBehind 的 DetailTable 中访问 FooterText (Telerik-RadGrid)?
【发布时间】:2012-06-29 09:12:59
【问题描述】:

我的 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 重写这些代码?

提前致谢

【问题讨论】:

  • 您是否在任何地方使用 DetailTableDataBind 事件处理程序?
  • 另外,在 ItemDataBound 事件处理程序中,您可以捕获此时 e.Item.ItemType 为 Footer 和 style 的情况。

标签: c# asp.net telerik footer radgrid


【解决方案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");
}

你就完成了。

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 感谢您的回答/但在这些示例中没有 DetailTable!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多