在ASP.NET中使用jquery访问列拖放网格视图行的数据 [英] Access the data of columns drag drop gridview rows with jquery in ASP.NET
本文介绍了在ASP.NET中使用jquery访问列拖放网格视图行的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码可以将行从一个网格拖动到另一个网格,现在我想访问第二个网格视图中的列并将其保存到数据库中。
如何获取值第[i]列?!
我尝试过:
这是我的代码
I have a code that can Drag Rows from one grid o another one and now I want to access the columns in the second gridview and save it into the database.
how can I get the values of column[i]?!
What I have tried:
This is my code
$(function () {
var sourceCount = $("#gvSource").find('tr:not(tr:first-child)').length;
var destCount = $("#gvDest").find('tr:not(tr:first-child)').length - 1;
$(".drag_drop_grid").sortable({
items: 'tr:not(tr:first-child)',
cursor: 'crosshair',
connectWith: '.drag_drop_grid',
axis: 'y',
dropOnEmpty: true,
receive: function (e, ui) {
if (e.target.id == 'gvDest') {
destCount++;
sourceCount--;
$('#hfSourceRowsCount').val(sourceCount);
$('#hfDestRowsCount').val(destCount);
}
else if (e.target.id == 'gvSource') {
destCount--;
sourceCount++;
$('#hfSourceRowsCount').val(sourceCount);
$('#hfDestRowsCount').val(destCount);
}
$(this).find("tbody").append(ui.item);
}
});
$("[id*=gvDest] tr:not(tr:first-child)").remove();
});
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[2] { new System.Data.DataColumn("Item"), new System.Data.DataColumn("Price") });
dt.Rows.Add("Shirt", 450);
dt.Rows.Add("Jeans", 3200);
dt.Rows.Add("Trousers", 1900);
dt.Rows.Add("Tie", 185);
dt.Rows.Add("Cap", 100);
dt.Rows.Add("Hat", 120);
dt.Rows.Add("Scarf", 290);
dt.Rows.Add("Belt", 150);
gvSource.UseAccessibleHeader = true;
gvSource.DataSource = dt;
gvSource.DataBind();
dt.Rows.Clear();
dt.Rows.Add();
gvDest.DataSource = dt;
gvDest.DataBind();
}
}
protected void Count(object sender, EventArgs e)
{
int rowsgvSource = Convert.ToInt32(hfSourceRowsCount.Value);
int rowsgvDest = Convert.ToInt32(hfDestRowsCount.Value);
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Source Count: " + rowsgvSource + "'); alert('Destination Count: " + rowsgvDest + "');", true);
}
推荐答案
(function(){
var sourceCount =
(function () { var sourceCount =
( #gvSource) .find(' tr:not(tr:first-child)')。length;
var destCount =
("#gvSource").find('tr:not(tr:first-child)').length; var destCount =
( #gvDest)。find(' tr:not(tr:first-child) )')。length - 1 ;
("#gvDest").find('tr:not(tr:first-child)').length - 1;
这篇关于在ASP.NET中使用jquery访问列拖放网格视图行的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文