我想隐藏中继器控件最后一行的下拉菜单。我使用了以下代码,但无法隐藏下拉菜单。
<asp:Repeater ID="RpFilter" runat="server" OnItemDataBound="rpFilter_DataBound">
<HeaderTemplate>
<table style=" border:1px solid #df5015; width:500px" cellpadding="0">
<tr style="background-color:#df5015; color:White">
<td colspan="2">
<b>Advanced Filter</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<table style="background-color:#EBEFF0;border-top:1px dotted #df5015; width:500px" >
<tr>
<td>
<asp:Label ID="lblField" runat="server" Text='<%# Eval("COLUMN_NAME")%>' Font-Bold="true"/>
</td>
<td>
<asp:DropDownList ID="ddlCondition" runat="server">
<asp:ListItem Text="Equals" Value="Equals"></asp:ListItem>
<asp:ListItem Text="Not Equals" Value="Not Equals"></asp:ListItem>
<asp:ListItem Text="Less Than" Value="Less Than"></asp:ListItem>
<asp:ListItem Text="Greater Than" Value="Greater Than"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtsearch" runat="server"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddlOperator" runat="server">
<asp:ListItem Text="AND" Value="AND"></asp:ListItem>
<asp:ListItem Text="OR" Value="OR"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnClose" runat="server" Text="Close"
class="fancybox-close" OnClick="btnCloseMsg_Click" />
<asp:Button ID="btnSearch" runat="server" Text="Search"
class="fancybox-close" OnClick="btnSearch_Click" />
</FooterTemplate>
</asp:Repeater>
后面的代码:
protected void rpFilter_DataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.ItemIndex == RpFilter.Items.Count - 1)
{
DropDownList Operator = (DropDownList)e.Item.FindControl("ddlOperator");
Operator.Visible = false;
}
}
}