I\'m creating one html table. I want to hide the table row. I\'m putting the attributes runat=server
and id
for the particular row, but the row has
When you add a runat='server'
to an HTML control you change the rendering and code blocks aren't supported inside. So if there are properties you need to change (style? class?) you probably have to instead of doing this:
<tr id='myrow' runat='server'>
<td>
your code here
</td>
</tr>
Do something like this:
<tr id='myrow' <%= GetRowProperties() %>>
<td>
your code here
</td>
</tr>
Note: runat='server'
removed from tr
. Then in your codebehind you can do something like this:
protected string GetRowProperties()
{
return "class='myclass'"; // something like this
}
You can use data binding to control the visibility of a control. That should solve your problem.
<tr runat="server">
some content...
<asp:PlaceHolder runat="server"
visible='<%# (strFlag=="d") || (strApprvdFlag=="y") %>'>
This content will only be rendered if strFlag is "d" or "y"
</asp:PlaceHolder>
more content...
</tr>
On your OnLoad method, you will need to call the DataBind() method to either the PlaceHolder, or any control that contains it, like the tr or even Page:
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
Page.DataBind();
}