【问题标题】:Conditionally hiding an html table built inside a template column有条件地隐藏在模板列中构建的 html 表
【发布时间】:2018-01-21 00:42:26
【问题描述】:

我已经构建了一个gridview,它在最左边包含一个绑定列,并且每隔一列是一个包含html 表的模板列。我这样做是因为我需要将 6 条信息整齐地组织到每个单元格中。但是,在某些情况下,填充这些模板 column-html 表的数据为空。在这种情况下,这些单元格仅显示 html 表格的空框。我想让 html 表在没有填充数据时完全消失。有谁知道我会怎么做?我假设我使用 onrowcreated 或 onrowdatabound 事件处理程序,但我不知道如何识别此表以将其设置为不可见。

非常感谢任何帮助。

【问题讨论】:

    标签: asp.net html-table


    【解决方案1】:

    解决方案

    1. 设置属性:<table border="0" cellpadding="0" cellspacing="0" style="boder:none 0px">/<table>
    2. 设置属性 runat="server" 和 id。 <table id="tblThis" runat="server"></table>

      在行数据绑定事件中

      if(e.Row.RowType == DataControlRow.DataRow) { var tbl= (Class_Of_HtmlTable)e.Row.FindControl("tblThis"); //Do whatever with table // tbl.Visible = false; }

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 2022-12-17
      • 2022-09-23
      • 2021-05-01
      • 2013-12-18
      • 2018-05-24
      • 1970-01-01
      • 2021-10-18
      • 2013-07-03
      相关资源
      最近更新 更多