code blocks are not supported in this context in asp.net control

前端 未结 2 1788
广开言路
广开言路 2021-01-17 14:12

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

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 14:23

    You can use data binding to control the visibility of a control. That should solve your problem.

    
    
        some content...
    
        
    
            This content will only be rendered if strFlag is "d" or "y"
    
        
    
        more content...
    
    
    

    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();
    }
    

提交回复
热议问题