【问题标题】:Setting value in footer label, gridview在页脚标签、gridview 中设置值
【发布时间】:2016-12-22 20:13:12
【问题描述】:

我不知道为什么它应该如此难以访问 gridview 模板中的内容..
我的 gridview 中有一个页脚模板,带有一个简单的“总和”标签,我需要将总小时数写入该标签。

我如何从服务器端(c#)访问这个标签?所以我可以在点击“计算”时设置我的结果。

ASP.net

  <FooterTemplate>
    <asp:Label ID="Labeltotaltimer" runat="server" Text=""></asp:Label>
   </FooterTemplate>´

我尝试过的许多解决方案之一:

 Label tst = (Label)GridViewrapport.FindControl("Labeltotaltimer");

让我更改按钮点击标签的简单修复??

【问题讨论】:

    标签: c# asp.net gridview


    【解决方案1】:

    你快到了。 FindControl 仅适用于直接子级,因此与其在 GridView 本身上调用它,不如在特定行(即页脚)上调用它。

    GridViewrapport.FooterRow.FindControl("Labeltotaltimer")
    

    【讨论】:

      猜你喜欢
      • 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
      相关资源
      最近更新 更多