Solved

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

Posted on 2014-10-16
2
159 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now