I'm trying to access a databound variable within a regular C# inline expression.
I was hoping there was some way I could access it using the Eval() command, but you cannot use it inside a regular inline code block. (What I mean by that, is the <% %> tag).
NOTE: The below inline code is not complete, I set the boolean (IsCommented) beforehand.
<%
if (IsCommented)
Response.Write("<a href='#' onclick='Comment(" + Eval("commentid") + "', $(this)); return false;' class='btn btn-info'>Comment</a>");
else
Response.Write("<a href='#' onclick='Comment(" + Eval("commentid") + "', $(this)); return false;' class='btn btn-inverse'>Commented!</a>");
%>
Is this at all possible?
(Note that I have this all contained within a ListView)
I am not getting your question properly,
But are you looking for something like this or will this solve your problem
<%if (IsCommented) {%>
<a href='#' onclick='Comment('<%#Eval("commentid")%>', $(this)); return false;' class='btn btn-info'>Comment</a>;
<%}else{%>
<a href='#' onclick='Comment('<%#Eval("commentid")%>', $(this)); return false;' class='btn btn-inverse'>Commented!</a>";
<%}%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With