Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net webgrid helper C# razor syntax

Posted on 2014-09-15
1
Medium Priority
?
578 Views
Last Modified: 2014-10-03
Hi experts,


I have asp.net mvc application, using VB and razor syntax.
My application works just fine.

Now i'm trying to convert this app into asp.net mvc application, using C# and razor.

I have a partial view in my VB application that looks like this. It works just fine.

Visual Basic webgrid

<div id="grid">

@grid.GetHtml(tableStyle:="table-condensed", _
                   headerStyle:="webgrid-header", _
                   footerStyle:="webgrid-footer", _
                   columns:=grid.Columns( _
                                        grid.Column("EmployeeID", "EmployeeID", format:=Function(str) Html.ActionLink(CType(str, System.Web.Helpers.WebGridRow).Value.employeeID, "Edit", "Form" & CType(str, System.Web.Helpers.WebGridRow).Value.EmployeeType, New With {.RegionNo = CType(str, System.Web.Helpers.WebGridRow).Value.DistrictNo, .RefNo = CType(str, System.Web.Helpers.WebGridRow).Value.EmployeeID}, New With {.class = "ActionLink"})), _
                                        grid.Column("FirstName", "First Name"), _
                                        grid.Column("LastName", "Last Name")
)
            )

</div>

Open in new window


I'm trying to translate this snippet into C# but I'm having trouble. The specific line i'm having trouble with is the first grid.column which looks like this:

grid.Column("EmployeeID", "EmployeeID", format:=Function(str) Html.ActionLink(CType(str, System.Web.Helpers.WebGridRow).Value.employeeID, "Edit", "Form" & CType(str, System.Web.Helpers.WebGridRow).Value.EmployeeType, New With {.RegionNo = CType(str, System.Web.Helpers.WebGridRow).Value.DistrictNo, .RefNo = CType(str, System.Web.Helpers.WebGridRow).Value.EmployeeID}, New With {.class = "ActionLink"})), _

Anyone know how I write this line in C# ?
0
Comment
Question by:maqskywalker
[X]
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
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 40326054
Here is my guess:

grid.GetHtml(tableStyle: "table-condensed", headerStyle: "webgrid-header", footerStyle: "webgrid-footer", columns: grid.Columns(grid.Column("EmployeeID", "EmployeeID", format: str => Html.ActionLink(((System.Web.Helpers.WebGridRow)str).Value.employeeID, "Edit", "Form" + ((System.Web.Helpers.WebGridRow)str).Value.EmployeeType, new {
                  RegionNo = ((System.Web.Helpers.WebGridRow)str).Value.DistrictNo,
                  RefNo = ((System.Web.Helpers.WebGridRow)str).Value.EmployeeID
            }, new { @class = "ActionLink" })), grid.Column("FirstName", "First Name"), grid.Column("LastName", "Last Name")));
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

704 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