我有保持在ListView
我分頁控件錶行如下(部分佈局):在ListView隱藏的錶行(ItemPlaceholderID行)
<asp:ListView ID="lvOrderItems" runat="server"
DataSourceID="odsShoppingCart"
DataKeyNames="ProductNumber"
ItemPlaceholderID="lvItemContainer">
<LayoutTemplate>
<table id="lvCart" runat="server">
<tr id="lvHeader" runat="server">
...
</tr>
<tr id="lvItemContainer" runat="server"></tr>
<tr id="lvPaging" runat="server">
...
</tr>
</table>
</LayoutTemplate>
在我的代碼隱藏,我處理數據綁定事件如下,我打算躲在整個lvItemContainer
行有條件(現在,我只是想隱藏的行本身沒有條件):
Protected Sub lvOrderItems_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles lvOrderItems.DataBound
Dim lvItemContainer As HtmlTableRow = CType(lvOrderItems.FindControl("lvItemContainer"), HtmlTableRow)
If Not lvItemContainer Is Nothing Then
Response.Write("hit1")
lvItemContainer.Visible = False
End If
Dim lvPaging As HtmlTableRow = CType(lvOrderItems.FindControl("lvPaging"), HtmlTableRow)
If Not lvPaging Is Nothing Then
Response.Write("hit2")
lvPaging.Visible = False
End If
End Sub
所以,當這個運行在DataBound
,hit1
是NE Ver解僱了,但hit2
是...任何想法這裏發生了什麼?
ListView很震驚,它期望一個TableRow ...'類型'System.Web.UI.WebControls.Panel'的值無法轉換爲'System.Web.UI.HtmlControls.HtmlTableRow'' –
採取runat = 「服務器」不在表聲明(和子元素)中,或者只是將該行的可見性設置爲false,因爲它已在服務器級別運行。 –
我已經從代碼隱藏中設置了'Visible = False',但沒有運氣。在閱讀關於ListView控件的更多信息時,它看起來像ListView用實際項目本身替換了「ItemPlaceholderID」內容......所以也許在構建ListView時,