Renz
Renz

Reputation: 91

Ajax.actionLink 1st paramter should be a value coming from the model

is there a way to pass the value of my model to the name(1st parameter) of the @Ajax.ActionLink? obviously this code has error

    @foreach (var item in Model)
    {
        <td>
            @Html.DisplayFor(modelItem => item.g_title)
        </td>
        @foreach (var grade in item.GradeList)
        {
            <td>
                @Ajax.ActionLink(grade.g_overall_student_score, "GradeSummary", "Employee", new { id = grade.g_id  }, new AjaxOptions { UpdateTargetId = "result" }) // error grade.g_overall_student_score is not acceptable 
            </td>
        }
    </tr>
    }

Upvotes: 1

Views: 21

Answers (1)

teo van kot
teo van kot

Reputation: 12491

First parameter of Ajax.ActionLink helper should be string so you can write like this:

@Ajax.ActionLink(grade.g_overall_student_score.ToString(), "GradeSummary", "Employee", new { id = grade.g_id  }, new AjaxOptions { UpdateTargetId = "result" })

Upvotes: 1

Related Questions