This is a migrated thread and some comments may be shown as answers.

Rearrange gridview rows by drag and drop

2 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 26 Jul 2013, 02:48 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 31 Jul 2013, 01:54 PM
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 >>
0
Jerry
Top achievements
Rank 1
answered on 01 Aug 2013, 03:23 PM
Desislava,

Thank you so much that is exactly what I needed.

I appreciate all your help.

Jerry
Tags
GridView
Asked by
Jerry
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jerry
Top achievements
Rank 1
Share this question
or