Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Html.DisplayFor -- Hide per User Request, ASP.net MVC4

Posted on 2013-12-13
1
706 Views
Last Modified: 2014-08-04
Does anyone have some ASP.net MVC4 "commandButton"
code that does something like the below step #2 ?

 1. page displays with all values below
 2. user decides they don't want to see the below
      "@Html.DisplayFor(modelItem => item.DR)"
     so they click a "HIDE/SHOW" button
 3. this field disappears, but all others remain visible
------------------------------------------------------------------------------------------------------------
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.IFSWO)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DR)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.RefDRNo)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ProjectID)
0
Comment
Question by:finance_teacher
1 Comment
 
LVL 5

Accepted Solution

by:
Jeroen Timmermans earned 500 total points
ID: 40198778
I'll assume item.DR is a boolean, you can add
@{if(item.DR)}
@{end if}

Open in new window


Around the bits you want to hide.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question