Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将参数从网格传递到javascript函数_C#_Asp.net Mvc - Fatal编程技术网

C# 将参数从网格传递到javascript函数

C# 将参数从网格传递到javascript函数,c#,asp.net-mvc,C#,Asp.net Mvc,目标 我试图从GRIDMVC中完成的是,在单击行中的按钮时,该行的ID将传递给onClick函数以执行我的计算 到目前为止我拥有的 到目前为止,我有我的网格与行,张贴下面是按钮的代码 colums.Add().Encoded(false).Sanitized(false).RenderValueAs(o => @Html.ActionLink("Add Row", "Create", "Student", new { o.student_id }, new { @class = "btn

目标

我试图从GRIDMVC中完成的是,在单击行中的按钮时,该行的ID将传递给onClick函数以执行我的计算

到目前为止我拥有的 到目前为止,我有我的网格与行,张贴下面是按钮的代码

colums.Add().Encoded(false).Sanitized(false).RenderValueAs(o => @Html.ActionLink("Add Row", "Create", "Student", new { o.student_id }, new { @class = "btn btn-primary btn-sm btn-block", @onclick = "studentChecker('{o.student_id}');" }));
问题

问题是,通过查看和尝试各种方法,我似乎无法将学生ID从行正确传递到studentChecker函数中


任何帮助或指向已经讨论过的链接都将不胜感激。

您需要传递
o.student\u id
的值,但是如果您编写
“studentChecker('{o.student\u id}');“
您正在向方法传递确切的字符串
{o.student\u id}
。为了传递实际值,请使用字符串连接写入不带引号的变量名称:

@onclick = "studentChecker('" + o.student_id + "');"

您需要传递
o.student\u id
的值,但如果您编写
“studentChecker({o.student\u id}”);
则将确切的字符串
{o.student\u id}
传递给该方法。为了传递实际值,请使用字符串连接写入不带引号的变量名称:

@onclick = "studentChecker('" + o.student_id + "');"

您是否尝试过
@onclick=“studentChecker”(“+o.student_id+”);“
?@ClaudiuGeorgiu-ahh所以这是我需要的“+”,请回答以便我可以选择。感谢您尝试了
@onclick=“studentChecker”(“+o.student\u id+”);“
?@ClaudiuGeorgiu-ahh所以这是我需要的“+”,请回答,以便我可以选择。谢谢