Reputation: 4404
I need this asp:TableRow to show conditionally.
<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>
How can I do this. I wrapped it in an
<asp:PlaceHolder ID="memberdues" runat="server">
tag but it complains:
Error 12 System.Web.UI.WebControls.TableRowCollection must have items of type 'System.Web.UI.WebControls.TableRow'. 'asp:PlaceHolder' is of type 'System.Web.UI.WebControls.PlaceHolder'.
I need this row to show conditionally.
I do this in 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;
}
Upvotes: 0
Views: 526
Reputation: 37533
Give it an ID and set its runat to server then you can access it from code behind.
<asp:TableRow runat="server" ID="rowExtraAmountType">
Now it's accessible from an event from behind:
rowExtraAmountType.Visible = (conditional expression);
Edit: Shown below with your question edits
<asp:TableRow runat="server" ID="memberdues">
Then the code behind:
memberdues.Visible = (DuesInfo.CredentialsAmount > 0);
Upvotes: 2