Im doing a project using SQL server 2000 and .NET 2003 (C#)
and i have this irritating problem :
In one of the tables, there is a column (Certification Type) which is a foreign key from Certifications table
The CertificationsType column is an Integer ... but i dont want the user to get to choose numbers from the Certification Type ComboBox , i want instead strings to appear in the combo box....
To sum up : I have a combobox that is supposed to carry int values, but i want instead strings to appear (and each string would refrence to a corresponding int value).
PLZZZZZZZZ HELP!!!!!!!!!!!!!! its URGENT!!!!!!!!?
i came up with this in mins, you'll need to make it error proof...
make an arraylist in your form
ArrayList Certification = new ArrayList();
then populate your combobox with the strings values, and fill your array as follows
Certification.Add(myCertificationIndex...
Certification.Add(CertificationIndex1_...
Certification.Add(myCertificationIndex...
Certification.Add(CertificationIndex2_...
and so on
optional:
iterate through your arraylist and fill the combobox with the strings values,
for (int i = 0; i %26lt; Certification.Count; ++i)
this.comboBox1.Items.Add(Certification [++i]);
now every time an item is selected in the combobox, you'll get the associated certificate index:
int CertIndex = Certification .IndexOf(this.comboBox1.SelectedItem)-1;
Reply:dont use direct linked db component to do this make an extra combobox and on dbcombo set an oncahnge event and then change extra combo`s inside
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment