Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net

eval

I want to display an additional <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 this possible? I get the following databinding error: does not contain a property with the name 'true'.

Any ideas on how to do this?

like image 868
Theomax Avatar asked Oct 09 '22 23:10

Theomax


1 Answers

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

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

If this doesn't help, edit your question and give a more detailed description of the issue and the objective.

EDIT

As for appending a row and a column, you can try this:

<%# Eval("SomeColumn") == DBNull.Value ? " " : String.Format("<tr><td>{0}</td></tr>", Eval("AnotherColumn")) %>
like image 110
James Johnson Avatar answered Oct 18 '22 01:10

James Johnson