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

RadGridView crashing

1 Answer 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mark
Top achievements
Rank 1
mark asked on 11 Jun 2009, 05:16 PM
I'm trying to rebind same grid to different datatables. The problem occurs when after sort by column gridview is rebound. During rebind it crashes bypassing catch..

Has anyone come across this (run this method , sort the gridview on any columns and run method again)

 try
            {
                 dt = new DataTable();
                 

                 dt.Columns.Add(new DataColumn(string.Format("{0}{1}", "x", (new Random()).Next(1, 20))));
                    dt.Columns.Add(new DataColumn(string.Format("{0}{1}", "y", (new Random()).Next(43, 320))));
                     

                for (int i = 0; i < 15; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = (new Random()).Next(1, 90);
                    Thread.Sleep(100);
                    dr[1] = System.Convert.ToDouble("1." + (new Random()).Next(1, 203222));

                    dt.Rows.Add(dr);

                }
                dt.AcceptChanges();


                this.dataGrid1.DataContext = dt;
                this.dataGrid1.Rebind();
            }
            catch (Exception e)
            {
                string x = e.Message;
                return;

            }

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Jun 2009, 05:40 AM
Hi mpytlik,

Please clear the grid sort and group descriptions before modifying ItemsSource to avoid such problems:
...
            this.dataGrid1.SortDescriptions.Clear();
            this.dataGrid1.GroupDescriptions.Clear();

            this.dataGrid1.ItemsSource = dt;
...


All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
mark
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or