将表数据从视图传递到控制器不起作用
我正在尝试将具有动态值的表格数据发送给控制器。
<tbody>
@if (ViewBag.data != null)
{
foreach (var item in ViewBag.data)
{
<tr>
<td class="AutoId">@item.AutoID <input type="hidden" name="AutoID" value="@item.AutoID" /></td>
<td class="hove" name="text"><a href="#"> <b>@item.Text</b></a><br /><label></label></td>
<td class="Active">@item.Active</td>
<td id="oBy" name="OrderBy">@item.OrderBy</td>
</tr>
}
}
表结构
上面是我使用的
<script>
$(document).ready(function () {
alert("Test 1");
$("#btnSave").click(function (e) {
alert("Test 2");
$.ajax({
type: "POST",
url: '@Url.Action("LookupManagementUpdate", "Admin", new { Area = "Admin" })',
data: $(".hove").val(),
dataType: 'json',
async: false,
success: function (response) {
Success = true;
},
error: function (response) {
},
});
});
});
</script>
的控制器代码
public string LookupManagementUpdate(string text)
{
return "answer"+Request["text"]+text;
}
以下ajax调用以发送一个字段...下面是我尝试使用请求和参数方法获取数据但未显示表数据 。 这是基于AC#MVC ADO.NET项目
I am trying to send the data of my table with dynamic values to the controller.
<tbody>
@if (ViewBag.data != null)
{
foreach (var item in ViewBag.data)
{
<tr>
<td class="AutoId">@item.AutoID <input type="hidden" name="AutoID" value="@item.AutoID" /></td>
<td class="hove" name="text"><a href="#"> <b>@item.Text</b></a><br /><label></label></td>
<td class="Active">@item.Active</td>
<td id="oBy" name="OrderBy">@item.OrderBy</td>
</tr>
}
}
above is the table structure
I am using below ajax call to send one field for example...
<script>
$(document).ready(function () {
alert("Test 1");
$("#btnSave").click(function (e) {
alert("Test 2");
$.ajax({
type: "POST",
url: '@Url.Action("LookupManagementUpdate", "Admin", new { Area = "Admin" })',
data: $(".hove").val(),
dataType: 'json',
async: false,
success: function (response) {
Success = true;
},
error: function (response) {
},
});
});
});
</script>
Below is my controller code
public string LookupManagementUpdate(string text)
{
return "answer"+Request["text"]+text;
}
I tried using both Request and parameter method to fetch the data but it does not display the table data.
This is a c# mvc ado.net based project
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用ajax.beginform和Ajaxoptions Onsuccess
try using Ajax.BeginForm and ajaxOptions Onsuccess