Grid/Combo load ..

K

kk

I have 2 issues, please help !


1st issue :
--------------------------------------------------------
Loading Grid
------------
1) creating new rows in a datatable and adding data a
array list to datatable.

ArrayList arrData = new ArrayList();
arrData = Employee.GetAll();

DataTable dt = new DataTable();
DataRow dr = new DataRow();
for(i=0; i< arrData.Count; i++)
{
dr = dt.NewRow();
dr["Age"] = ((Employee)arrData).Age;
dr["Name"] = ((Employee)arrData).Name;
dr["Object"] = arrData;
}

2) From datatable populating the grid
Total time taken for this is 40 secs.
Grid.DataSource = dt;

Clicking on tabs at runtime with grids in each tab
--------------------------------------------------
3) Even though the grid is loaded with data, it takes
full 20 secs for the grid to show on each tab when
switching between tabs at runtime. Grid painting is
time consuming.

2nd issue:
----------------------------------------------------------
Tried the InsertAt after the data binding and it did not
work, complained that positions for items cannot be
changed. Also tried inserting before the binding,
although there were no runtime errors, the "All" entry was
overwritten by the databinding.

public static void LoadCombo(System.Windows.Forms.ComboBox
cbo, ICollection data, string display, string key)
{
ArrayList arData = (ArrayList) data;
if (arData.Count == 0)
{
cbo.DataSource = null;
}
else
{
cbo.DataSource = arData;
cbo.DisplayMember = display;
cbo.ValueMember = key;
cbo.Items.insert(0,"All"); -- Did not work
}


-----Original Message-----

first issue... don't know. send code sample.


2nd issue - after binding add a new item.
mycbobox.Items.Insert(intPosToInsertAt,"ALL")

Nick Harris, MCSD
http://www.VizSoft.net




.
..
 
N

Nick Harris

1. when you say dr = dt.NewRow() all your sayingis create a empty row using
the schema from this datatable. After you create the empty row, and add are
your field values, you still must add the row to the data table.

dt.Rows.Add(dr);

2. Yes grid painting is time consuming, but should be that much. In 20
seconds I can generally load and transform 4000 records. Something is up w/
your code. Use Show_plan in sql to check your sql performance. Then ensure
that tab switching isn't rebinding your grids.

3rdly, the cbo issue, i answered the other day...I've never had the issue.
I will research it. Until then why don't you just
use

arData.Add("All")
or
arData.Insert(0,"All")

so that it is in the object that is being bound?

Nick Harris, MCSD
http://www.VizSoft.net

kk said:
I have 2 issues, please help !


1st issue :
--------------------------------------------------------
Loading Grid
------------
1) creating new rows in a datatable and adding data a
array list to datatable.

ArrayList arrData = new ArrayList();
arrData = Employee.GetAll();

DataTable dt = new DataTable();
DataRow dr = new DataRow();
for(i=0; i< arrData.Count; i++)
{
dr = dt.NewRow();
dr["Age"] = ((Employee)arrData).Age;
dr["Name"] = ((Employee)arrData).Name;
dr["Object"] = arrData;
}

2) From datatable populating the grid
Total time taken for this is 40 secs.
Grid.DataSource = dt;

Clicking on tabs at runtime with grids in each tab
--------------------------------------------------
3) Even though the grid is loaded with data, it takes
full 20 secs for the grid to show on each tab when
switching between tabs at runtime. Grid painting is
time consuming.

2nd issue:
----------------------------------------------------------
Tried the InsertAt after the data binding and it did not
work, complained that positions for items cannot be
changed. Also tried inserting before the binding,
although there were no runtime errors, the "All" entry was
overwritten by the databinding.

public static void LoadCombo(System.Windows.Forms.ComboBox
cbo, ICollection data, string display, string key)
{
ArrayList arData = (ArrayList) data;
if (arData.Count == 0)
{
cbo.DataSource = null;
}
else
{
cbo.DataSource = arData;
cbo.DisplayMember = display;
cbo.ValueMember = key;
cbo.Items.insert(0,"All"); -- Did not work
}


-----Original Message-----

first issue... don't know. send code sample.


2nd issue - after binding add a new item.
mycbobox.Items.Insert(intPosToInsertAt,"ALL")

Nick Harris, MCSD
http://www.VizSoft.net




.
.
 

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