Solved

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

Posted on 2013-12-13
1
698 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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 …

776 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