if the va...">

ASP.NET Eval () problem displaying two columns if Eval ()! = Null

I want to display extra <tr><td> <?# Eval("DataValue") %> </td></tr>if the value of another Eval () data item is not null.

I have the following aspx:

   <%# Eval(TwoColumns).ToString() == null ? " " : Eval(Column2Data).ToString() %>

Is it possible? I get the following data binding error: does not contain a property named "true".

Any ideas on how to do this?

+5
source share
3 answers

I'm a little unsure what you are asking for, but try something like this:

<%# Eval("SomeColumn") == DBNull.Value ? " " : Eval("AnotherColumn") %>

If this does not help, edit your question and give a more detailed description of the problem and purpose.

EDIT

As for adding row and column, you can try the following:

<%# Eval("SomeColumn") == DBNull.Value ? " " : String.Format("<tr><td>{0}</td></tr>", Eval("AnotherColumn")) %>
+3
source

:

<%# (Eval("TwoColumns") == null) ? " " : Eval("Column2Data").ToString() %>

.ToString() , Eval null NullReferenceException.

0
<%# Eval("SomeColumn").Equals(DBNull.Value) ? "" : "<td>" + Eval("AnotherColumn") + "</td>" %>
0

All Articles