Refresh Data in RadListView problem

6 posts, 0 answers
  1. Michael Topf
    Michael Topf avatar
    23 posts
    Member since:
    May 2010

    Posted 15 Mar 2012 Link to this post

    Hi, 

    I have a RadListview on a form connected to a datasource. Then I have a timer which call a method that refreshs the content of the DataTable periodically.  After starting it shows the content correctly. But as soon as the DataTable is refreshed for the first time I ran into problems. 

    The RadListView itself seems not to recognize when the underlying DataTable is changing. That's no problem so I have to tell the RadListView to refresh. My first try was the Refresh() Method. That seemed not to work. So I've tried to reassign the DataTable to the RadListView in setting it again as DataSource. This will throw an exception that a column is not contained in the table (more precisely it's the first column). Looking in to the underlying DataTable the column is included.

    Wrapping the commands into BeginUpdate() and EndUpdate() makes no change.

    Surely I have something overlooked to make it work. Any help is welcome.

    Michael

  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 19 Mar 2012 Link to this post

    Hi Michael,

    Thank you for contacting us.

    RadListView should automatically detect changes when the underlying collection is a DataTable and when you refill it. The following code snipped demonstrates this scenario:
    SchedulerDataDataSet ds = new SchedulerDataDataSet();
     
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        AppointmentsTableAdapter adapter = new AppointmentsTableAdapter();
        adapter.Fill(ds.Appointments);
        this.radListView1.DataSource = ds.Tables[0];
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        AppointmentsTableAdapter adapter = new AppointmentsTableAdapter();
        adapter.ClearBeforeFill = true;
        adapter.Fill(ds.Appointments);
    }

    Note that the above approach will work if you are refilling the same collection. If you are initializing a new collection, then you should reset the DataSource. However, due to an issue in RadListView, resetting the DataSource results in the exception you have mentioned. I have logged this issue to PITS and we will address this in a future release. Here you can find the PITS entry. To workaround this issue, just set the DataSource to null before resetting it with the new collection:
    this.radListView1.DataSource = null;
    this.radListView1.DataSource = ds.Tables[0];

    I hope this will help you. Your Telerik points have been updated since you are the first one to report this issue. Should you have any further questions, feel free to ask.

    Regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jay
    Jay avatar
    11 posts
    Member since:
    Mar 2012

    Posted 02 Apr 2012 Link to this post

    I have a similar problem. I have a radlistview that connected to a Data Source. On Form1, and on another form you can add a new item to the datatable. But the rad list doesn't get refreshed. I'm not too good with C# so I'm not really clear on how to get it to refresh. I tried to call the refresh method. I tried to use the event handler for collectionChanged and collectionChanging. These get call but only when I exit the app. is there a way that as soon as the database table changes i can get notified and then refresh the radlistview?
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 04 Apr 2012 Link to this post

    Hello Jay,

    The Refresh method is a method of the base Control class in the .NET framework and it only causes a repaint of the control.

    In regards to updating the data in RadListView, it should automatically reflect the changes if they are made to the same data source object. For example, if we have a dataset called dataSet1 which has a table named Users and we have a RadListView and a RadGridView controls bound to the same data table:

    this.radListView1.DataSource = this.dataSet1.Users;
    this.radGridView1.DataSource = this.dataSet1.Users;

    then when you edit something in the grid view, the changes will be automatically reflected in the list view. This is possible, because the edit operations are applied over the same collection.

    If you are changing the database from another application, then you should refill the data table by using a table adapter:

    this.usersTableAdapter.ClearBeforeFill = true;
    this.usersTableAdapter.Fill(this.dataSet1.Users);

    This will retrieve fresh data from the database and fill the Users table with it. RadListView will automatically reflect the changes to the Users table and display the newly retrieved data.

    I hope you find this useful. If you have any further questions, we will be glad to address them.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  6. Jay
    Jay avatar
    11 posts
    Member since:
    Mar 2012

    Posted 10 Apr 2012 Link to this post

    I'm doing it this way but its still not working. I have a list view when i double click an item it brings a document form i can edit the user name. After i edit the name i call an update list function that has the tableadapter.fill() call.

    I figured it out.
  7. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 13 Apr 2012 Link to this post

    Hello Jay,

    The Fill method retrieves data from the database and fills the dataset with it. I am not sure about your exact scenario, but you might want to call the Update method of the TableAdapter when you finish editing an item.

    If you still experience difficulties, you can open a new Support Ticket, where you can attach a sample project demonstrating your scenario. Additionally, please provide us with a detailed description of the functionality that you want to achieve. This will let us investigate your case and provide you with proper support.

    Looking forward to hearing from you.

    Regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready