want to make panel visible depend upon condition
i tried
Visible='<%#Convert.ToBoo开发者_运维百科lean(((Session["AccountId"].ToString()=="1")||
(Session["AccountID"].ToString()==""))?true:false) %>'
i want to make panel visible=true when session id=1 if not false..
above coding is not working any suggestionPlease take some care in formatting code.
You return true if the value is "1" or empty (""), which is in your case, always
You can use this:
Visible = '<%= Session["AccountId"].ToString()=="1" %>'
This will write the result of the expression (which is a boolean value) as a string ("True" or "False"). And most probably this will work as well:
Visible = '<%= Session["AccountId"] == 1 %>'
I've not tried your one but the below one does work:
Visible='<%# (Session["AccountId"] ?? "").ToString() == "1" ? true : false%>'
精彩评论