如何将表数据传递给MVC中的控制器 [英] How to pass table data to controller in MVC

查看:58
本文介绍了如何将表数据传递给MVC中的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为List< place>属性的模型

地方有类似

地名的属性,

placedescription



现在我有两个文本框来输入地名和描述,之后我点击添加按钮,这些数据插入到jquery的Add按钮下方的表格中。因此,表格行正在增加。



< table id =tblPlacelist> 
< thead>
< tr>
< th>地名< / th>
< th>地点描述< / th>
< / tr>
< / thead>
< tbody>< / tbody>
< / table>





现在问题是,如何将表格行数据作为列表传递?



我采取了部分剃刀视图和列表< place>在视图上方声明。



我尝试过:



与上述相同的问题。

解决方案

检查出来 - 如何将HTML表格行作为列表/数组发布到MVC控制器 [ ^ ]。


创建jquery函数将表数据传递给contoleer







函数SaveData(){



//创建数组对象以将表数据推入其中。

var selected = new Array();

//将表格数据推入其中。



('#table_bodyID tr')。each(function(){

selected.push({

JsonObject1:

I have a model with property named List<place>
place has property like
placename,
placedescription

now I have two textboxes to enter placename and description, after that I'm clicking add button and those data inserted in a table tbody just below the Add button by jquery. So table row is increasing.

<table id="tblPlacelist">
<thead>
<tr>
<th>Place Name</th>
<th>Place Description</th>
</tr>
</thead>
<tbody></tbody>
</table>



Now the thing is, how can I pass the table row data as list?

I have taken a partial razor view and the list<place> declared above of the view.

What I have tried:

The same problem what described above.

解决方案

Check this out - How to Post HTML Table Rows as a List/Array to MVC Controller[^].


Create jquery function to pass the table data into contoleer



function SaveData() {

//Create array object to push the table data into it.
var selected = new Array();
//Push the table data into it.


('#table_bodyID tr').each(function () {
selected.push({
JsonObject1:


这篇关于如何将表数据传递给MVC中的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆