aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT
Advertise Here

Advertize

wwwSW
Posted by Aamir Hasan   on Sunday, August 14, 2011 Total Views:  

In this article, i will demonstrates how to use jQuery UI sortable (drag & drop) with ASP.NET Repeater Control. Through Jquery UI Sortable plugin, we can drag and drop the selected items with the mouse.

Using jQuery UI with ASP.NET Repeater control, you will able to drag and drop selected row with the mouse.

I have added jQuery UI CDN reference as given below.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"

        type="text/javascript"></script>




Drag and drop operation will be perform by using jQuery UI sortable plugin as given below.

<script>

        $(function () {

            $("#table1 tbody.rep-drag").sortable({

                revert: true

            });

            $("#table1 tbody.rep-drag").disableSelection();

 

        });

</script>

 

Note:If you will not add jQuery libarary and  the jQuery UI plugin you will not get the output.



Let’s start


Open your Visual Studio. Create Web Site, create a page called  “Repeater-jQuery-UI-Sortable.aspx”.


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>jQuery UI sortable (drag & drop) with ASP.NET Repeater Control | aspxtutorial.com

    </title>

    <style>

        #table1

        {

            width: 500px;

            font-size: .80em;

            font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif;

            margin: 0px;

            padding: 0px;

            color: #666;

        }

        #table1 th

        {

            border-bottom: 1px solid #eee;

            border-top: 1px solid #eee;

            height: 29px;

            text-align: left;

            padding-left: 10px;

            background-color: #fafafa;

        }

        #table1 td

        {

            border-bottom: 1px solid #eee;

            padding-left: 10px;

        }

        tr{ cursor:pointer;}

    </style>

 

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"

        type="text/javascript"></script>

 

</head>

<body>

    <form id="form1" runat="server">

    <style>

        .demo ul

        {

            list-style-type: none;

            margin: 0;

            padding: 0;

            margin-bottom: 10px;

        }

        .demo li

        {

            margin: 5px;

            padding: 5px;

            width: 150px;

        }

    </style>

    <script>

        $(function () {

 

            $("#table1 tbody.rep-drag").sortable({

                revert: true

            });

            $("#table1 tbody.rep-drag").disableSelection();

 

        });

    </script>

    <div>

        <p>

            <h1>

              jQuery UI sortable (drag & drop) with ASP.NET Repeater Control

            </h1>

        </p>

        <asp:Repeater ID="Repeater1" runat="server">

            <HeaderTemplate>

                <table id="table1">

                    <thead>

                        <tr>

                        <th>

                                Sr.#

                            </th>

                            <th>

                                Title

                            </th>

                            <th>

                                Author

                            </th>

                            <th>

                                Price

                            </th>

                        </tr>

                    </thead>

                    <tbody class="rep-drag">

            </HeaderTemplate>

            <ItemTemplate>

                <tr>

                <td>

                        <%# ((Book)Container.DataItem).Id %>

                    </td>

                    <td>

                        <%# ((Book)Container.DataItem).Title %>

                    </td>

                    <td>

                        <%# ((Book)Container.DataItem).Author %>

                    </td>

                    <td>

                        <%# ((Book)Container.DataItem).Price %>

                    </td>

                </tr>

            </ItemTemplate>

            <FooterTemplate>

                </tbody>

                <tfoot>

                    <tr>

                        <th colspan="2">

                            &nbsp

                        </th>

                        <th>

                            <div id="total">

                            </div>

                        </th>

                    </tr>

                </tfoot>

                </table>

            </FooterTemplate>

        </asp:Repeater>

    </div>

    <a href="http://aspxtutorial.com" title=".NET Articles">.NET Articles </a>

    <p>

        Author:Aamir Hasan</p>

    </form>

</body>

</html>




Following is the  “Repeater-jQuery-UI-Sortable.aspx.cs” code given below.


public partial class Repeater_jQuery_UI_Sortable : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        Repeater1.DataSource = Display();

        Repeater1.DataBind();

    }

 

    public List<Book> Display()

    {

        List<Book> Obj = new List<Book>()

        {

            new Book{ Id=1, Title="ASP.NET C#", Author="Aamir Hasan", Price= 101.1F},

            new Book{ Id=2,Title="ASP.NET Control", Author="Aamir Hasan", Price= 120.1F},

            new Book{ Id=3,Title="ASP.NET Development", Author="Aamir Hasan", Price= 140.1F},

            new Book{ Id=4,Title="ASP.NET Desing Pattern", Author="Aamir Hasan", Price= 50.1F},

            new Book{ Id=5,Title="Sharepoint 2010 Administration", Author="Aamir Hasan", Price= 70.1F},

            new Book{ Id=6,Title="Sharepoint 2010 Development", Author="Aamir Hasan", Price= 80.1F},

            new Book{ Id=7,Title="jQuery", Author="Aamir Hasan", Price= 90.1F},

            new Book{ Id=8,Title="HTML 5", Author="Aamir Hasan", Price= 20.1F},

            new Book{ Id=9,Title="Javascript", Author="Aamir Hasan", Price= 40.1F},

            new Book{ Id=10,Title="ASP.NET C#", Author="Aamir Hasan", Price= 70.1F}

        };

 

        return Obj;

    }

 

    public class Book

    {

        public int Id { get; set; }

        public string Title { get; set; }

        public string Author { get; set; }

        public float Price { get; set; }

    }

 

 

}


Output

Download

Repeater-jQuery-UI-Sortable.rar (1.84 kb)

See live demo

 

Protected by Copyscape Online Plagiarism Tool

Comments (22) -

chronograph watches from Oris or Hamilton for men for you to know then better if you want to buy one

tiffany jewelry
tiffany jewelry United States
8/31/2011 12:56:58 AM #

A great post but How to select a cool Tiffany jewelry. we sell Tiffany jewelry We are the best store provided various cheap Tiffany jewelry but only a little white to make cheap designer handbags

John R.
John R. United States
9/9/2011 5:15:44 AM #

Great post… I am trying to institute an async call back to update the sort after the drop. Have you venture into this area? I am able to intercept the onmouseup event on the row but this doesn’t seem feasible.

John R.
John R. United States
9/9/2011 5:16:09 AM #

Great post… I am trying to institute an async call back to update the sort after the drop. Have you venture into this area? I am able to intercept the onmouseup event on the row but this doesn’t seem feasible.

John R.
John R. United States
9/9/2011 5:16:35 AM #

Great post… I am trying to institute an async call back to update the sort after the drop. Have you venture into this area? I am able to intercept the onmouseup event on the row but this doesn’t seem feasible.

John R.
John R. United States
9/9/2011 5:16:51 AM #

Great post… I am trying to institute an async call back to update the sort after the drop. Have you venture into this area? I am able to intercept the onmouseup event on the row but this doesn’t seem feasible.

John R.
John R. United States
9/9/2011 5:28:51 AM #

Sorry for the multiple post but you get a Null insert error if you select "Notify me when new comments are added."

Magento Develope
Magento Develope United Kingdom
9/26/2011 12:31:34 AM #

This is an excellent post. I really appreciate with you. I enjoyed the post. Thanks for sharing.

nfl jerseys from china
nfl jerseys from china United States
10/7/2011 6:42:48 PM #

Top post. I look forward to reading more. Cheers

Web Design Sheffield
Web Design Sheffield United Kingdom
10/20/2011 4:01:56 AM #

Thanks for this great and interesting article. I really enjoyed the article. It's really useful and informative for me.

Burberry Outlet
Burberry Outlet People's Republic of China
11/3/2011 5:16:47 PM #

together with Burberry Diaper Bags, we can say Burberry Outlet enable you to have the perfect condition all the time, Burberry Sale invites you to visit more at http://www.burberrybags-outlets.com

monster beats
monster beats People's Republic of China
12/1/2011 3:50:31 PM #

outperforms just by medical doctor dre Substantial is higher than excellent has expanded in which smaller sized businesses out of doors the house, tidal lower intense curiosity with all the widespread, even though factors audio a higher level good quality can be very great,<a href=' http://www.monsterbeatsdrdrestore.com/'>; beats detox </a> as well as excellent firm in advance of a version of a a par. dr dre overcom While generally, your speak fully, clear, temptations success are going to be quite amazing;<a href=' http://www.monsterbeatsdrdrestore.com/'>; beats by dre review </a> Have with quiet. Noticed lower regarding terrific outcome, a tiny bit of seem to be. Produce prospects all around employing unwanted attractive appears to be top-notch via just like, utilize a several obtaining. There are this superb course, incorporates the following very good energy source. To assist you to power know-how generally,<a href=' http://www.monsterbeatsdrdrestore.com/'>; beats by dre pro </a> by using style that you can set-up further buy, that has a brand-new grow older about very little many people replace, which propensity with all the community for your increased and the development. large enhances simply by physician dre. above hearing.

Web design sheffield
Web design sheffield United States
12/2/2011 2:43:36 AM #

Thanks for taking the time to discuss about this, I feel strongly about it and love learning more on this topic. If possible, would you mind updating your blog with more information? It is extremely helpful for me.
http://www.2jdesign.co.uk/

barbour ashby
barbour ashby People's Republic of China
12/2/2011 4:35:39 PM #

There are many brands of barbour Shoreman Jacket in the market today. Each of the brand promises to bring out something new to the customers. barbour fusilier is also a renowned and reputed brand in the market. This brand is in fact reputed for the jackets barbour . You can purchase a Barbour enduro leather jacket and you would be amazed to find yourself. There are different varieties in the barbour jacket that you would get in the market.We will try to provide you few varieties of the barbour scott bracken jacket that are available in the market. The barbour jackets is basically a classically designed and styled Barbour combat coat. http://www.uk-barbourjacket.com/

Timberland Boots
Timberland Boots United States
12/4/2011 11:32:18 PM #

555ce9
http://www.cheaptimberlandforyou.com/

Magento Developer
Magento Developer United Kingdom
12/7/2011 3:14:18 AM #

I found this article is really useful for me in my job. Thanks for sharing this useful information.
http://www.2jdesign.co.uk/

Magento Developer
Magento Developer United Kingdom
12/7/2011 3:14:30 AM #

I found this article is really useful for me in my job. Thanks for sharing this useful information.
http://www.2jdesign.co.uk/

Dallas Alarm Monitoring
Dallas Alarm Monitoring United States
12/8/2011 6:34:30 AM #

Very cool post. I just recently started following your blog, but I look forward to contributing more in the future.

Multistore oscommerce
Multistore oscommerce United Kingdom
12/8/2011 11:46:49 PM #

This is an excellent information over here. You have provided very valuable and useful information in this post.
www.oscprofessionals.com/.../...re-oscommerce.html

Multistore oscommerce
Multistore oscommerce United Kingdom
12/8/2011 11:46:59 PM #

This is an excellent information over here. You have provided very valuable and useful information in this post.
www.oscprofessionals.com/.../...re-oscommerce.html

Multistore oscommerce
Multistore oscommerce United Kingdom
12/8/2011 11:47:20 PM #

This is an excellent information over here. You have provided very valuable and useful information in this post.
www.oscprofessionals.com/.../...re-oscommerce.html

Multistore oscommerce
Multistore oscommerce United Kingdom
12/8/2011 11:54:03 PM #

This is an excellent information over here. You have provided very valuable and useful information in this post.
www.oscprofessionals.com/.../...re-oscommerce.html

Multistore oscommerce
Multistore oscommerce United Kingdom
12/8/2011 11:56:37 PM #

This is an excellent information over here. You have provided very valuable and useful information in this post.
www.oscprofessionals.com/.../...re-oscommerce.html

fddf
fddf People's Republic of China
3/31/2012 9:11:06 PM #

http://www.louisvuittononlineoutletus.com

cheap tiffany jewelry
cheap tiffany jewelry People's Republic of China
4/19/2012 10:58:13 PM #

          
http://www.tiffany-cool.com          
www.tiffany-cool.com/tiffany-silver-necklaces.html          
www.tiffany-cool.com/.../...yst-rings-SR0152A.html          
          

fafafa
fafafa Slovenia
4/23/2012 2:11:37 AM #

http://www.christianlouboutinukk.org   christian louboutin
http://www.tiffanyuks.org   tiffany uk
http://www.gucciukbeltuk.org   gucci belt
http://www.frsaclouisvuittonsac.com   louis vuitton sac
http://www.chanelukoutletuks.org   chanel outlet
http://www.burberryukoutletuk.org   burberry
http://www.poloralphlaurenuko.org   ralph lauren uk

fake oakley sunglasses
fake oakley sunglasses Nigeria
5/6/2012 11:17:27 PM #

http://www.oakley-glasses2012.com fake oakley sunglasses
We have the oakley sunglasses discount-www.oakley-glasses2012.com/...s-discount_c-27.html, although it is the best fake oakley sunglasses-http://www.oakley-glasses2012.com arequality, we have fake Oakley sprots sunglasses-www.oakley-glasses2012.com/...asses_c-29.html,fake Oakley lifestyle sunglasses-www.oakley-glasses2012.com/...asses_c-30.html,fake Oakley active sunglasses-www.oakley-glasses2012.com/...asses_c-31.html,fake Oakley polarized sunglasses-www.oakley-glasses2012.com/...lasses_c-32.html,Our new oakley sunglasses-www.oakley-glasses2012.com/...asses-2012_c-33.html have oakley sunglasses 2012-www.oakley-glasses2012.com/.../...45_p-298075.html

Pingbacks and trackbacks (2)+

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5