Combo box weirdness

J

Jayyde

Can someone help me figure out why 2 combo boxes on the same form with the
same method of adding a "(Select One)" option to the top of the data source
aren't both working? Actually I have about 12 combo boxes and all but 1 are
loading without any problems.

Code for ones that are working:
**************************************************************
ds = boProductStatus.GetDataSet();

DataRow row = ds.Tables[0].NewRow();

row[ProductStatusDCSchema.ProductStatusId] = -1;

row[ProductStatusDCSchema.DisplayName] = "(Select One)";

ds.Tables[0].Rows.InsertAt(row,0);

this.cboProductOrganizationStatus.ValueMember =
ProductStatusDCSchema.ProductStatusId;

cboProductOrganizationStatus.DisplayMember =
ProductStatusDCSchema.DisplayName;

cboProductOrganizationStatus.DataSource = ds.Tables[0];

**********************************************************



Code for one that isn't working:

**********************************************************

ds = boProductType.GetDataSet();

DataRow row = ds.Tables[0].NewRow();

row[ProductTypeDCSchema.ProductTypeId] = -1;

row[ProductTypeDCSchema.DisplayName] = "(Select One)";

ds.Tables[0].Rows.InsertAt(row,0);

cboProdType.ValueMember = ProductTypeDCSchema.ProductTypeId;

cboProdType.DisplayMember = ProductTypeDCSchema.DisplayName;

cboProdType.DataSource = ds.Tables[0];

**********************************************************



The 2nd one is throwing a "There's no position 0" error when it loads. I
added a watch and looked at the ds, it has the "(Select One)" showing at
[0]. I can't for the life of me figure out what's going on with this and I
don't think it'll help me to stare at it alone any longer ;).



TIA!

-Jayyde
 
J

Jayyde

Ammendment: It's a "There is no row at position 0" error. Also if I take
out the parentheses and make it just "Select One" it works just fine.

-Jayyde
 

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