Here i have explained how to Drag and Drop Gridview Rows in Asp.Net C#.

Step 1) Add HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Drag and Drop Gridview Rows in Asp.Net C#.</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="jquery.tablednd.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#gvDetails").tableDnD();
})
</script>
</head>
<body>
<form id="form1" runat="server">
<h1>Drag and Drop Gridview Rows in Asp.Net C#.</h1>
<div>
<asp:GridView ID="gvDetails" runat="server"> </asp:GridView>
</div>
</form>
</body>
</html>

Step 2) Import Namespaces

using System;
using System.Data;

Step 3) C#

protected void Page_Load(object sender, EventArgs e)
{
BindGridviewData();
}
    
//Dynamically create & bind data to gridview
protected void BindGridviewData()
{
DataTable dt = new DataTable();
dt.Columns.Add("UserId", typeof(Int32));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Education", typeof(string));
dt.Rows.Add(1, "Imran Khan", "B.Tech");
dt.Rows.Add(2, "Fatima Ali", "BA");
dt.Rows.Add(3, "Ram Shankar", "MS");
dt.Rows.Add(4, "Narendra Tiwari", "B.Tech");
dt.Rows.Add(6, "Mani Anuragam", "MD");
dt.Rows.Add(7, "Waseem Mirza", "B.Tech");
dt.Rows.Add(8, "Bilal Ahmed", "CA");
gvDetails.DataSource = dt;
gvDetails.DataBind();
}

Screenshot

Add Comments