How Do I Remove A Table Column In Mvc?
I want have two columns and based on a condition, include or remove a third. using all the if statements seems a bit redundant. Is there another way to do this? Copy
But if you want to remove the entire column, rather than inhibiting the display of the values, then if
statements are perfectly fine.
<tr><td><%= Model.Name.ToString().Trim() %></td><td><%= Model.Age.ToString().Trim() %></td>
<% if (myCondition) { %>
<td><%= Model.Other.ToString().Trim() %></td>
<% } %>
</tr>
By the way, it appears from your code sample that you need a loop. You could also benefit from some Html encoding. Something like this:
<% foreach (Person item inModel) { %>
<tr><td><%= Html.Encode(item.Name) %></td><td><%= Html.Encode(item.Age) %></td>
<% if (myCondition) { %>
<td><%= Html.Encode(item.Other) %></td>
<% } %>
</tr>
<% } %>
Solution 2:
if you are using table then hide the column showing Other value:
<% for(......){
//evaluate here if you will show it or not?var showOther = Age > 18 ? "block":"none";
%>
<tr><td>..</td><td>..</td><tddisplay="<%= showOther %>">..</td></tr>
<% }%>
As A Row
I need your help, if the following code below counts every …
How To Make A Transition Effect Up The Input On Change
I need to place this particular effect on a dropdown I need…
Some Questions About Tree Construction [html Spec]
I know that it's not customary to ask a bunch of questi…
Post a Comment for "How Do I Remove A Table Column In Mvc?"