我需要这个asp:TableRow来有条件地显示。
<asp:TableRow>
<asp:TableCell><asp:Label id="ExtraAmountType" runat="server" Width="182px"></asp:Label></asp:TableCell>
<asp:TableCell Width="10%" HorizontalAlign="Right">$ <asp:textbox id="MembershipDues" runat="server" Wrap="False" BackColor="#FFFF80" AutoPostBack="True" Width="31px" MaxLength="3" ontextchanged="MembershipDues_TextChanged"></asp:textbox></asp:TableCell>
</asp:TableRow>我该怎么做呢。我把它包在一个
<asp:PlaceHolder ID="memberdues" runat="server"> 标记,但它会抱怨:
错误12 System.Web.UI.WebControls.TableRowCollection必须具有“System.Web.UI.WebControls.TableRow”类型的项。“‘asp:PlaceHolder”的类型为“System.Web.UI.WebControls.PlaceHolder”。
我需要有条件地显示此行。
我在Page_Load中做到了这一点:
memberdues.Visible = false;
if (DuesInfo.CredentialsAmount > 0)
{
// do some other stuff to populate the variables in the placeholder then show it
memberdues.Visible = true;
}发布于 2012-11-14 06:21:17
给它一个ID,并将它的runat设置为server,然后你就可以从后台代码访问它了。
<asp:TableRow runat="server" ID="rowExtraAmountType">现在可以从后面的事件访问它:
rowExtraAmountType.Visible = (conditional expression);编辑:如下所示,包含您的问题编辑
<asp:TableRow runat="server" ID="memberdues">然后是后面的代码:
memberdues.Visible = (DuesInfo.CredentialsAmount > 0); https://stackoverflow.com/questions/13369842
复制相似问题