2011-12-08 20 views
1

我已經構建了一個gridview,其中包含最左邊的一個綁定列,而其他每列都是包含html表的模板列。我這樣做是因爲我需要整齊地將6條信息組織到每個單元格中。但是,在某些情況下,填充這些模板列-html表的數據爲空。當這種情況發生時,這些單元格只顯示html表格的空白框架。我想使html表格在沒有填充數據時完全消失。有誰知道我會怎麼做呢?我假設我使用onrowcreated或onrowdatabound事件處理程序,但我不知道如何識別此表以便將其設置爲不可見。有條件地隱藏模板列內部構建的html表格

任何幫助是極大的讚賞。

回答

1

解決方案

  1. 套裝屬性:<table border="0" cellpadding="0" cellspacing="0" style="boder:none 0px">/<table>
  2. 集屬性RUNAT = 「服務器」 和id。 <table id="tblThis" runat="server"></table>

    在RowDataBound事件

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