Jay Shukla
Jay Shukla

Reputation: 792

How to use ActionLink in MVC WebGrid?

I am use a WebGird in my MVC Demo application and I'm trying to use ActionLink in WebGrid how can I use it?

View:-

@model IEnumerable<RotationManager.Models.tableCustomer_M>
@{
    WebGrid listGrid = new WebGrid(Model);
}

 @listGrid.GetHtml(tableStyle: "table", footerStyle: "foot",
    columns: new[]{
     listGrid.Column("Customer_Id",format: (item) => Html.ActionLink(item.Customer_Id, "Edit",new {@id=item.Customer_Id},null))
    })

Above line of code isn't work.

Please help me!

Any help will be appreciated!

Upvotes: 1

Views: 8703

Answers (1)

Splendor
Splendor

Reputation: 1396

@listGrid.GetHtml(tableStyle: "table", footerStyle: "foot",
    columns: new[]{
     listGrid.Column(header: "Customer_Id", format: item => new HtmlString(
                     Html.ActionLink((string)item.Customer_Id.ToString(), 
                    "Edit", new { @id = item.Customer_Id} ).ToString()))
    })

Upvotes: 3

Related Questions