473,323 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Changing bit values in DataTable?

Hi,

I was wondering if there is a quicker way to do this? I have a select all
check box for data in a grid and when checked I want the checkboxes in the
grid to be checked.

I am currently using:

foreach(DataRowView DRV in dvData)
{
DRV["BIT_print_label"] = this.chkSelectAll.Checked;
}

It is very slow for a large amount of data, approx 1888 records. Can anyone
suggest a faster way. I am using VS2005.

Tim
Mar 30 '06 #1
1 3430
Tim,

I did as simple test which took about 0.5 seconds to run using this.

DataTable dataTable = dvData.Table;
dataTable.BeginLoadData();

bool checkedValue = this.chkSelectAll.Checked;
int labelCol = dvData.Table.Columns.IndexOf("BIT_print_label");
foreach(DataRowView DRV in dvData)
{
DRV[labelCol] = checkedValue;
}
dataTable.EndLoadData();

It does some simple caching. I'm not sure why your code is taking so
long to run?
Do have any events such as RowChanging or ColumnChanging that are being
fired?

Are you using a grid that's redrawing itself as you change each record?

You might also consider filtering the DataTable using SELECT to get
those that need BIT_print_label changing:
DataTable dataTable = dvData.Table;
dataTable.BeginLoadData();

bool checkedValue = this.chkSelectAll.Checked;
DataRow[] changes = dataTable.Select("BIT_print_label = " + (!
checkedValue));
int labelCol = dvData.Table.Columns.IndexOf("BIT_print_label");
foreach(DataRow row in changes)
{
row[labelCol] = checkedValue;
}
dataTable.EndLoadData();

Mar 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Greg Scharlemann | last post by:
Given some recent success on a simple form validation (mainly due to the kind folks in this forum), I've tried to tackle something a bit more difficult. I'm pulling data down from a database and...
6
by: spmm_pls | last post by:
Hi, Could some1 please tell me what the best way is to adjust the value of a column in my databound datagrid (in ASP.NET) For example my database returns the values 1,2 and 3 in the column...
3
by: Mike | last post by:
I've got an app with a DataTable that gets passed around and modified by datagrids on 3 different asp.net pages. Not all columns need to be displayed, but I need them all in the datagrid so I can...
1
by: Geoff Jones | last post by:
Hi Is it possible to change the type of data a column holds in DataTable at runtime? For example, suppose that the table column originally holds Strings, can we, at runtime, change it to...
2
by: Oenone | last post by:
Something I've found quite useful to do in my code is to select a record from my database which may or may not exist, and then if I find that it doesn't exist to add it to the datatable before I...
5
by: gbattine | last post by:
Hi guys, i've a very important question for you,i'm stopped my work from 10 days to solve it,but nothing.... i hope your can help me. I'm developing a jsf application and i've created a datatable...
9
by: =?Utf-8?B?UGV0ZXJX?= | last post by:
I have a TabControl on a Windows form in which I have various tab pages each with a DataGridView, the first column of which is a DataGridViewCheckBoxColumn and subsequent columns being...
0
by: John Wright | last post by:
I have a datagrid that contains a list of decimal values. I want to compare the values of one datatable to the other datatable and update my data grid. For example my first datatable has the...
1
rizwan6feb
by: rizwan6feb | last post by:
I have a DataTable with thousands of records, i want to show these records on per page basis ( i.e a DataGridView showing first 20 records and next button to show next 20 records ...) To achieve...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.