Solved

asp.net webgrid helper C# razor syntax

Posted on 2014-09-15
1
509 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
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 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

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

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…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 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

19 Experts available now in Live!

Get 1:1 Help Now