Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
I want to use drag option to move row of gridview. But using my code, drag is not is working.

What I have tried:

**// using C# code**
    protected void Page_Load(object sender, EventArgs e)
        {
    DataTable dt = new DataTable();
        DataRow row = null;
    System.Data.DataColumn tColumn = null;      // TABLE COLUMNS. 

            tColumn = new System.Data.DataColumn("Database Column", System.Type.GetType("System.String"));
            dt.Columns.Add(tColumn);
            dt.Rows.Add("Title");
            dt.Rows.Add("FirstName");
            dt.Rows.Add("MiddleName");
            dt.Rows.Add("LastName");
    GridView3.DataSource = dt;
            GridView3.DataBind();
    }

**//using .aspx code**
        <asp:GridView ID="GridView2"  CellPadding="5" CellSpacing="0"  OnRowDataBound="GridView2_RowDataBound" 
                        ForeColor="#333"          runat="server">

                        <HeaderStyle BackColor="#989898" ForeColor="white" />

                    </asp:GridView>
        **// .js code**
        <script type="text/javascript">
               $(document).ready(function () {
                   $("#GridView2").tableDnD();
               });
    </script>


I am using code, but this code is not working.
After editing..
My JS plugins:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="https://github.com/isocra/TableDnD/blob/master/js/jquery.tablednd.0.7.min.js" type="text/javascript"></script>
Posted
Updated 5-Sep-19 1:25am
v3
Comments
F-ES Sitecore 5-Sep-19 7:07am
   
I don't see any code that enables drag and drop?

Regardless, google something like "drag drop reorder table rows jquery" and you'll probably find code\plug-ins to do this.
Member 14576724 5-Sep-19 7:19am
   
yes, i am using js plugin. Please check again my edited question.
F-ES Sitecore 5-Sep-19 7:46am
   
"Not working" means nothing, it doesn't give anyone enough information to help you. You'll need to debug your code starting from the beggining...so view the source and check there is an element with an id of "GridView2" on your page. If there is check $("#GridView2").length to make sure it is at least 1. If your code doesn't get that far then your issue will either be the order your things are on the page or your IDs are not what you expect. If the length is 1 or more then the problem is elsewhere.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100