Using databinder syntax inside a TD on aspx page?
I'm thinking this sh开发者_运维知识库ould be possible or something like it:
<td <%# "style=" DataBinder.Eval(Container.DataItem, "CustName") == "T" ? "border:none" : "border:solid"%>>
But it's not doing it for me.
Is there a way to do this?
Thanks!
I am not sure but try this
<td <%# string.Format("style={0}, Eval("CustName") == "T" ?
"border:none":"border:solid")%> >
or Create a public method on the cs file like this
protected string GetStyle()
{
var dt = SomeMethod();
If (string.compare("T",dt.rows[idx][idx].Tostring(),false)==0)
return "border:none";
return "border:solid";
}
user:
<td <%# string.Format("style={0}, GetStyle())%> >
I don't know if you can do that, but you can try this instead:
<td style='<%# Eval("CustName") == "T" ? "border:none" : "border:solid"%>'>
</td>
精彩评论