Rearrange gridview rows by drag and drop

3 posts, 1 answers
  1. Jerry
    Jerry avatar
    46 posts
    Member since:
    Mar 2012

    Posted 26 Jul 2013 Link to this post

    I'm using telerik tools version v.2013.1.32120

    I want to populate a radGridView from an oracle or sas data table and then set AllowRowReorder = True and allow the user to rearrange the rows however they want locally and then I can handle the database update.  My issue now is that I pull my data down into a C# datatable on the client and then when I set it as the source for my radGridView it will not let me rearrange the data.  How can I change this to be unbound mode to allow the rearranging within the datatable but not on the server table?

    using (OracleConnection oraConn = new OracleConnection(sConn))
    {
       OracleCommand sasCommand = oraConn.CreateCommand();
       sasCommand.CommandType = CommandType.Text;
       sasCommand.CommandText = sSQL;
     
       OracleDataAdapter da = new OracleDataAdapter(sasCommand);
       DataTable dt = new DataTable();
     
       try
       {
         oraConn.Open();
         da.Fill(dt);
         radGridView1.DataSource = dt;
       }
       catch
       {
       }
      }


    Thank you,
  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3907 posts

    Posted 31 Jul 2013 Link to this post

    Hello Jerry,

    Thank you for contacting Telerik Support.

    You can not use DataSource and AllowRowReorder=true simultaneously to achieve your goal. If you have a DataTable filled with the necessary data, you should iterate it to populate manualy the RadGridView. Thus you can allow reordering rows. Please have a look at the following code snippet:
    private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.
                this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
     
                foreach (DataColumn col in nwindDataSet.Customers.Columns)
                {
                    this.radGridView1.Columns.Add(col.ColumnName);
                }
     
                foreach (DataRow row in nwindDataSet.Customers.Rows)
                {
                    this.radGridView1.Rows.Add(row.ItemArray);
                }
     
                this.radGridView1.AllowRowReorder = true;
            }

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Jerry
    Jerry avatar
    46 posts
    Member since:
    Mar 2012

    Posted 01 Aug 2013 Link to this post

    Desislava,

    Thank you so much that is exactly what I needed.

    I appreciate all your help.

    Jerry
Back to Top