DataTable performance

J

Jameson

Hi,

Is there any way to create multiple new rows in a DataTable, or execute
"batches" of operations on the table, rather than having events fired on
each and every operation? For example, if I want to add 1,000 rows to the
table but I don't want it to fire 1,000 row added events, how can I do this?
I'm making a visualisation component with data binding and having to update
the visualiser every time a DataTable event occurs when those events are so
minor (and tend to come along in batches) seems a little wasteful (and is
very slow). My only option at the moment is to enforce a
BeginUpdate/EndUpdate pair on the visualiser the programmer must call before
making changes to the DataTable, which kind-of makes the whole data binding
concept a little pointless (i.e. changes in the table are automatically
reflected in the bindee).

I'm new to DataTable and binding, so maybe I've missed something!


Thanks for any advice you can give me.




J.
 
A

Alberto Poblacion

Jameson said:
[...] if I want to add 1,000 rows to the table but I don't want it to fire
1,000 row added events, how can I do this?

Call BeginLoadData on the DataTable before starting the operation, use
LoadDataRow to add your rows, and then call EndLoadData at the end. This
disables constraints and notifications on the datatable while you are
inserting the rows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top