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
5 Answers, 1 is accepted
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
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
I figured it out.
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