Solved

asp.net webgrid helper C# razor syntax

Posted on 2014-09-15
1
527 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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