connectseekers.com

Friday, 13 June 2014

Drag Drop Cells in GridView Control Using Asp.net C# and jQuery

6/13/2014 - By Pranav Singh 0

In this article I will show you how you can Drag Drop Cells in GirdView Control Using Asp.net C# and jQuery. 

Now for this article first we will create a new asp.net application and add required controls in it.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="draganddropgridvirecell.aspx.cs"
    Inherits="ProjectDemo_Asp.et.draganddropgridvirecell" %>

<!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 runat="server">
    <title>Drag Drop Cells in GirdView Control Using Asp.net C# and jQuery</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <script>
        $(function () {
            $("#GridView1").find("td").draggable({ revert: "valid", cursor: "move" });
            $("#GridView1").find("td").droppable({
                drop: function (event, ui) {
                    $(this).html($(ui.draggable).html());
                }
            });
        })
    </script>
    <style>
        #GridView1 td
        {
            cursor: move;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" EmptyDataText="There are no data records to display."
            BorderStyle="Solid">
            <Columns>
                <asp:BoundField DataField="author_name" HeaderText="NAME" />
                <asp:BoundField DataField="publisher_name" HeaderText="PUBLISHER NAME" />
                <asp:BoundField DataField="publication_year" HeaderText="PUBLISH YEAR" />
                <asp:BoundField DataField="retail_price" HeaderText="PRICE" />
            </Columns>
            <HeaderStyle BackColor="#66CCFF" />
        </asp:GridView>
    </div>
    </form>
</body>
</html>

In above code I have used jquery drag able attribute for this article

    <script>
        $(function () {
            $("#GridView1").find("td").draggable({ revert: "valid", cursor: "move" });
            $("#GridView1").find("td").droppable({
                drop: function (event, ui) {
                    $(this).html($(ui.draggable).html());
                }
            });
        })
    </script>

Now bind the grid view and check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top