Solved

asp.net webgrid helper C# razor syntax

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

20 Experts available now in Live!

Get 1:1 Help Now