How to Add item to Dropdownlistbox dynamically?

I have a datawindow(dw_coll_excsel) which has a dropdownlistbox(select_exc_flag). The values of this dropdownlistbox are hardcoded. But on a certain condition, i want to add an item to this dropdownlistbox from the open event of the window. This is what I have given, but i am getting an error. The type of select_exc_flag is Number, but it has display values as strings. How do I incorporate that here.
I want to insert the 17th row with data value as "Acct is coded to rep 96"

This is what I have done:
dw_coll_excsel.InsertRow(0)
string s
int row
s = "Acct is coded to rep 96"
IF A = "SUPPLY" THEN
row=dw_coll_excsel.object.select_exc_flag[1].AddItem(17)
END IF
taniatangriAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

michaelstoffelCommented:
While I would highly recommend switching to a dddw instead of a ddlb, you can modify the values using:

dw.Object.column.Values = "displayval~tactualval/displayval2~tactualval2......"

So, from your example:

string ls_ddlbValues
long ll_flagValue

s = "Acct is coded to rep 96"
IF A = "SUPPLY" THEN
   ls_ddlbValues = dw_coll_excsel.object.select_exc_flag.Values
   ls_ddlbValues += '/' + s + '~t' + string(ll_flagValue)
   dw_coll_excsel.object.select_exc_flag.Values = ls_ddlbValues
END IF

Remember, just like a dddw the list is the same for every row.  If it changes based on row, you should definitely use a dddw and one of the different techiniques used to filter the dropdown per row.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
taniatangriAuthor Commented:
Thanks a lot! Your solution solved my problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.