Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3622
  • Last Modified:

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
0
taniatangri
Asked:
taniatangri
1 Solution
 
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
 
taniatangriAuthor Commented:
Thanks a lot! Your solution solved my problem.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now