Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.
i'm able to drag data from one gridview to another gridview. but not able to save the dragged data in to database.some one please help me.

in aspx page i use
--------------------

XML
<script src="js/jquery-1.8.0.js" type="text/javascript"></script>
    <script src="js/jquery-ui.js" type="text/javascript"></script>
    <link href="css/jquery-ui.css" rel="stylesheet" type="text/css" />


<script type="text/javascript">
    $(function () {
        $(".drag_drop_grid").sortable({
            items: 'tr:not(tr:first-child)',
            cursor: 'crosshair',
            connectWith: '.drag_drop_grid',
            axis: 'y',

            dropOnEmpty: true,
            receive: function (e, ui) {
                $(this).find("tbody").append(ui.item);
            }
        });
        $("[id*=gvDest] tr:not(tr:first-child)").remove();
    });
</script>





cs
--
C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {
           DataTable dt = new DataTable();
           dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Item"), new 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();
       }
   }

but i am not able to retrieve data from gvDest and insert into database. please help me to find a solution
Posted
Updated 22-Jul-14 0:55am
v2
Comments
Sampath Lokuge 22-Jul-14 7:30am    
At which place (i.e. Code snippet) you're going to save those data ?
[no name] 22-Jul-14 7:37am    
There is no code here that you have tried to save anything to any database.
pachooooos 23-Jul-14 1:24am    
i tried to add but its not working, so i just tried to print the first row in the destiantion grid.. but its not giving any value even after drag and drop.

private void adddata()
{



foreach (GridViewRow g1 in gvDest.Rows)

{

Response.Write("<scrip>alert('" +g1.Rows[i].Cells[1].ToString()+ "i');</script>");

}





}

thank you ..
pachooooos 23-Jul-14 1:27am    
but its giving value when i print rows in gvSource

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900