Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
332
Re: some help with Rows.AddRange()
posted

Hi Mike,

I understand the AddRange method is undocumented and not intended for general use; however I am inclined to figure out how to use it and implement it in my application for a very particular reason.

At the start of a client application, the app will automatically synchronize a series of data from a server - and populate a datasource on the client application with that data. With the very limited number of rows to add, this isn't an issue worth discussing; however with a larger number of rows to add (for example more than 100 rows), I am having trouble getting the DataGrid to display properly since it is bound to this datasource, and the datasource is bogged down with the Add command being called 100 times within the last second.

In my previous posts on this forum, I have concluded that when adding more than one row to a datasource of all types, I should use the AddRange method instead of calling the Add method for each individual row. Please provide some sort of example in using the AddRange method for the UltraDataSource.

From my understanding, the AddRange method takes a single object-array in its signature. I assume this object-array can be an array of string values representing each cell values of a row? Furthermore, each row I am adding to the datasource requires its Tag object referencing a particular object in my application. How would I assign an object to the Tag field of the new row when instantiating the object-array?

Finally, I understand that each time I call the Add method, a series of Events are raised to inform bound controls of a new row. For example, the RaiseAddEvents. Even just by being able to disable these events until after adding my 100th row should probably improve the efficiency of my system; what do you think?

Regards,

Kel

Parents
No Data
Reply
  • 2070
    posted

    Hi Kel,

     

    AddRange method is for design-time serialization/deserialization and it's not meant to be used outside of that. If you want to add multiple rows without raising notifications, call SuspendBindingNotifications and then add multiple rows and then call ResumeBindingNotifications. This should be efficient because only a single notification will be sent out to bound controls when ResumeBindingNotifications is called instead of one for each add.

     

    Hope this helps, 

    Sandip 

     

Children