By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

Why is datagrid update SO slow?

P: n/a
VM
I have a 35000 line datagrid and updating one field in all 35000 rows takes
an eternity. How come? Since I don't have the datasource available (it may
be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi,

Well, it depends on the grid. However, why would you need 35000 records?
What grid are you talking about? Did you try BeginUpdate/EndUpdate?
It is a bad idea having that many records in a grid.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"VM" <vo******@yahoo.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
I have a 35000 line datagrid and updating one field in all 35000 rows takes an eternity. How come? Since I don't have the datasource available (it may
be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.

Nov 16 '05 #2

P: n/a
VM,

Well, the fact that you are performing 35000 updates is part of it. I
would recommend actually going to the data source, updating all 35000 rows,
then calling AcceptChanges on the table/view that they are in. This should
make it faster.

It would be nice if the grid supported the ability to not update itself
during an operation, but in order to do this, you will have to detach the
data source, update the table, and then reattach.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"VM" <vo******@yahoo.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
I have a 35000 line datagrid and updating one field in all 35000 rows takes an eternity. How come? Since I don't have the datasource available (it may
be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.

Nov 16 '05 #3

P: n/a
VM
But in the process of updating the windows datagrid I also update an ascii
file by writing each row (in our case, 35000) to the file. And the whole
process of opening the file, writing to it 35,000.times, and closing takes
less than a second (almost instantaneous). So imagined it'd be almost the
same speed.
"VM" <vo******@yahoo.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
I have a 35000 line datagrid and updating one field in all 35000 rows takes an eternity. How come? Since I don't have the datasource available (it may
be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.

Nov 16 '05 #4

P: n/a
VM
It's a Windows datagrid. Basically, I use the grid to load the file to it,
modify certain aspects of the file through the grid, and write the grid to
the file. These files are usually HUGE and our goal is to be able to do this
with 1.6 million records (which means 1.6m rows). So 35,000 isn't that many
considering what we have to accomplish. And although a normal user will only
highlight a few records and update the file with those few records, we're
prepping up to the possibility that a user will want to highlight and modify
all 35,000 records.

The datagrid is mostly a visual commodity so the user knows what he has
updated (ie. when a user highlights one record and right-clicks, the grid
will update column X with the words "right-clicked"). Now, If we highlight
all 35,000 records, it'll have to go to all 35,000 rows and write
"right-clicked". That's what takes so long.

It was either the grid or a listview.

Angel

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:#K*************@TK2MSFTNGP11.phx.gbl...
Hi,

Well, it depends on the grid. However, why would you need 35000 records?
What grid are you talking about? Did you try BeginUpdate/EndUpdate?
It is a bad idea having that many records in a grid.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"VM" <vo******@yahoo.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
I have a 35000 line datagrid and updating one field in all 35000 rows

takes
an eternity. How come? Since I don't have the datasource available (it may be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.


Nov 16 '05 #5

P: n/a
VM
How can I get the datasource from a datagrid?
I was thinking of getting the datasource, be it a dataview or datatable,
cast it, and then do all the necessary changes. Since I don't know what the
source may be, I don't want to write some code for a datatable and even more
code if it's a dataview.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ur**************@tk2msftngp13.phx.gbl...
VM,

Well, the fact that you are performing 35000 updates is part of it. I
would recommend actually going to the data source, updating all 35000 rows, then calling AcceptChanges on the table/view that they are in. This should make it faster.

It would be nice if the grid supported the ability to not update itself during an operation, but in order to do this, you will have to detach the
data source, update the table, and then reattach.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"VM" <vo******@yahoo.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
I have a 35000 line datagrid and updating one field in all 35000 rows

takes
an eternity. How come? Since I don't have the datasource available (it may be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.


Nov 16 '05 #6

P: n/a
Why dont you only update the file and just refresh the grid, instead of
modifying grid rows. Refreshing grid should reflect the modified data.

"VM" <vo******@yahoo.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
But in the process of updating the windows datagrid I also update an ascii
file by writing each row (in our case, 35000) to the file. And the whole
process of opening the file, writing to it 35,000.times, and closing takes
less than a second (almost instantaneous). So imagined it'd be almost the
same speed.
"VM" <vo******@yahoo.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
I have a 35000 line datagrid and updating one field in all 35000 rows

takes
an eternity. How come? Since I don't have the datasource available (it may be a table or view), in my example I do it like this:

for (int i=0;i<34000;i++) //the first 2000 records took 2 mins.
{
dataGrid_auditAddress[i, 5] = "MARKED";
}

Any help would be appreciated.


Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.