Click here to Skip to main content
15,175,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
var gridTotal = new WebGrid(qOrdersList);

The result of the above query is a table with some columns including: AuditNum (an int) and Status. I want to display it in a webgrid with this code:
HTML
@gridTotal.GetHtml(       
            columns : gridTotal.Columns
            (
                gridTotal.Column(
                    columnName : "AuditNum",
                    format: @<a href="@App.PathOrderEdit?AuditNum=x">x</a> 
                    ),
                gridTotal.Column(
                    columnName : "Status")
            )
        );

The problem is the link that I want to create. 'x' is going to be the value of AuditNum column for the current row that I want it to be the text of the link and also be used in the href attribute as a parameter. I dont know how to access that. Example:

AuditNum ---- Status
100 ------------ A
101 ------------ B
.
.
.
I want to make those 2 numbers a link to these pages:

@App.PathOrderEdit?AuditNum=100
@App.PathOrderEdit?AuditNum=101
Posted

1 solution

You should modify your code as follows:
HTML
@gridTotal.GetHtml(       
            columns : gridTotal.Columns
            (
                gridTotal.Column(
                    columnName : "AuditNum",
                    format: @<a href="@App.PathOrderEdit?AuditNum=@item.AuditNum">@item.AuditNum</a> 
                    ),
                gridTotal.Column(
                    columnName : "Status")
            )
        );
   
Comments
cs101000 5-Jan-13 10:33am
   
Thanks a lot for the quick answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900