Bound ComboBox very slow to load

  • Thread starter Thread starter David D Webb
  • Start date Start date
D

David D Webb

I am populating several ComboBox's on a page by binding them to a query from
an SQLCE table. The page is very slow to load and flashes in a bad way.
There are 4 dropdowns on the page and each has about 10 items in it. The
table is indexed on the category_id cloumn and I am using the latest service
packs.

I bound them for simplicity so that I could use the SelectedValue property.
Would it help to do this another way? Use a filter on the DataSet or
populate this manually using an SqlCeCommand object and Items.Add()?

Also, since the DataSet is created in a method, am I responsible for any
cleanup on it. I am guessing the ComboBox maintains the reference to it so
it doesn't get disposed until the ComboBox goes away.

Thanks,
Dave


static public void LoadDropdown(int category_id, ComboBox ddLookup, int
selected_id)
{
string sSQL = "SELECT id, descr FROM lookup WHERE category_id = " +
category_id.ToString();
DataSet dsetLookup = new DataSet();
SqlCeDataAdapter daptLookup = new SqlCeDataAdapter(sSQL, Db.conn);
daptLookup.Fill(dsetLookup, "Lookup");
ddLookup.DataSource = dsetLookup.Tables["Lookup"];
ddLookup.DisplayMember = "descr";
ddLookup.ValueMember = "id";
ddLookup.SelectedValue = selected_id;
}
 
Back
Top