Solved

apply formatting and styles to MVC view (migration from gridview)

Posted on 2014-10-16
2
160 Views
Last Modified: 2014-10-17
hi,
I am teaching myself a bit of MVC web design. I have a asp.net VB site that I want to try and convert some features to MVC.

I have got my data in a vbhtml page showing, but I need to apply some rules

ie,

convert

   @Html.DisplayFor(Function(modelItem) item.FLT_INCIDENT )

to say something like, if item.FLT_INCIDENT value is 2, then display the word Request.

I used to use

  If e.Row.Cells(2).Text = "2" Then
                e.Row.Cells(2).Text = "Request"
                RequestImage.Visible = True
            Else
                e.Row.Cells(2).Text = "Incident"
                IncidentImage.Visible = True

            End If

Open in new window


when it was in a Grid View.

I don't understand if I should use a helper function or not.
0
Comment
Question by:Steven Wells
2 Comments
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 500 total points
ID: 40386337
Hi,

You may use If operator, that will
@Html.DisplayFor(Function(modelItem) If(item.FLT_INCIDENT = "2","Request","Incident") )

Open in new window


Giannis
0
 
LVL 12

Author Comment

by:Steven Wells
ID: 40386391
Cool. Thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

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