如何将jQuery表的数据发送到SQL
我有一个带有属性设置为可排序的jQuery表(我可以拖放行),
<script type="text/javascript">
$(function () {
$("#tblLookup1 tbody").sortable({
items: 'tr',
cursor: 'pointer',
axis: 'y',
dropOnEmpty: false,
start: function (e, ui) {
ui.item.addClass("selected");
},
stop: function (e, ui) {
$("#tblLookup1 tbody tr").each((idx, tr) => {
$("td:nth-child(4)", tr).text(idx+1);
});
ui.item.removeClass("selected");
},
receive: function (e, ui) {
$(this).find("tbody").append(ui.item);
}
});
});
现在在更新了名称偏好的列后,第一行将具有偏好值= 1,2nd low = 2,等等...
现在,这些值可以使用,直到我刷新页面为止。为了进行永久更改,我想用新的首选项值更新数据库。
这是基于.NET MVC ADO的Web应用程序
ques)如何将这些偏好值存储到某个列表中,然后将其传递/发布到SQL数据库。
查看文件代码
<thead>
<tr >
<th>ID</th>
<th>Name</th>
<th>Active</th>
<th>Order By</th>
</tr>
</thead>
<tbody>
@if (ViewBag.data != null)
{
foreach (var item in ViewBag.data)
{
<tr>
<td>@item.AutoID</td>
<td>@item.Text<br </td>
<td >@item.Active</td>
<td>@item.OrderBy</td>
</tr>
}
}
</tbody>
I have a jquery table with property set to sortable( I can drag and drop rows),
<script type="text/javascript">
$(function () {
$("#tblLookup1 tbody").sortable({
items: 'tr',
cursor: 'pointer',
axis: 'y',
dropOnEmpty: false,
start: function (e, ui) {
ui.item.addClass("selected");
},
stop: function (e, ui) {
$("#tblLookup1 tbody tr").each((idx, tr) => {
$("td:nth-child(4)", tr).text(idx+1);
});
ui.item.removeClass("selected");
},
receive: function (e, ui) {
$(this).find("tbody").append(ui.item);
}
});
});
Now after sorting a column with the name preference gets updated, 1st row will have preference value=1, 2nd row =2 and so on...
Now these values are available until I refresh the page. So as to make permanent changes I want to update the database with the new preference values.
This is a .net MVC ado based web app
Ques) How can I store these preference values into some list and later pass on/post to sql database.
view file code
<thead>
<tr >
<th>ID</th>
<th>Name</th>
<th>Active</th>
<th>Order By</th>
</tr>
</thead>
<tbody>
@if (ViewBag.data != null)
{
foreach (var item in ViewBag.data)
{
<tr>
<td>@item.AutoID</td>
<td>@item.Text<br </td>
<td >@item.Active</td>
<td>@item.OrderBy</td>
</tr>
}
}
</tbody>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论