How to get index of an item in the DropDownByKey control?

Hi,
I'm new to PDK for .NET and I have a simple question about the "IndexOf" method of the items collection.
Attached a small test program:
Dim li As New DropDownListItem
li.Key = "A"
li.Text = "Zero"
DropDownByKey1.Items.Add(li)
li = New DropDownListItem
li.Key = "B"
li.Text = "One"
DropDownByKey1.Items.Add(li)
li = New DropDownListItem
li.Key = "C"
li.Text = "Two"
DropDownByKey1.Items.Add(li)
li = New DropDownListItem
li.Key = "D"
li.Text = "Three"
DropDownByKey1.Items.Add(li)
li = New DropDownListItem
li.Key = "E"
li.Text = "Four"
DropDownByKey1.Items.Add(li)
Dim liForSearch As New DropDownListItem
liForSearch.Key = "C"
liForSearch.Text= "Two"
Write(" Index --> " & DropDownByKey1.Items.IndexOf(liForSearch))
The output should be 2 but instead I get -1 (Not Found).
Why?
thanks,
Omri

Hi,
Since you have the Key of the listItem you are looking for you should get the item by applying:
liToSearch = DropDownListItem.Items[key];
int index = DropDownListItem.Items.IndexOf(liToSearch);
Regards,
Tsachi

Similar Messages

  • How to get specific folder and items in the document library sharepoint 2010

    I have a Shared library and it has Test folder and inside so many documents now i need to display the Test folder and items programmatically.
    Appreciate Help!!!!!
    Blitz

    This is how you could do it using the server object model -
    SPWeb site = SPContext.Current.Web;
    SPList list = site.Lists["listname"];
    SPQuery query = new SPQuery();
    SPFolder folder = list.RootFolder.SubFolders["FolderName"];
    query.Folder = folder;
    SPListItemCollection items = list.GetItems(query);
    foreach (SPListItem item in items)
    //do whatever you want here
    Please "Mark as Answer" if a post has answered your question or "Vote as Helpful" if it was helpful in some way. Here's
    why

  • How to get value from list item

    Hi all,
    How to get value from list item?
    I have a problem with the List Item object
    in the Oracle forms.
    How can I retrieve the selected item from
    a list ?
    I didn't find any function like 'list.GET_
    SELECTED_ITEM()'...
    thanks
    Bala

    Hello,
    You get the value as for any other Forms item:
    :value := :block.list_tem ;Francois

  • How to get Value of a item of first record when current record is second

    How to get Value of a item of first record when current record is second in Form6i ?
    get_item_instance_property dose not allow to get value.

    Gerd,
    You're right, there are several other triggers that must be coded, but I was responding to Steve's statement about Inserting or deleting records from the multi-record block. For the record, I use the following to manage a Record Group:
    * When-New-Block-Instance - Initialize the RG
    * block Post-Query - populate the RG
    * When-Create-Record - add new record to RG
    * When-Remove-Record - remove record from RG
    * block When-New-Item-Instance - capture previous value of the item or row
    * When-Validate-Item - Item specific Insert, Update, Delete of values in the RG
    There are a few other places as well, but these are the minimum. It might seem like a lot of code, but then again, I don't use this solution for every multi-line block. Like all tools, you use the right tool for the job. :-)
    Craig...

  • How can i create a new item in the app "health"?

    how can i create a new item in the app "health"? I need a field for documentation of "Waist-to-height ratio", exactly for "circumference".
    It's a matter of common knowledge, that the Waist-to-height ratio (WHtR) has more significance then the Body-Mass-Index (BMI).

    If you mean you want to change a color of a calendar category or create a new one, you cannot do that, what is pre-loaded is what you get and cannot be edited.

  • How to get my macbook to connect to the Apple TV?

    How to get my macbook to connect to the Apple TV in a strange apartment? I am housesitting for someone for a few months. They mentioned that i would be able to use their Apple TV to play stuff from my macbook. I am using their basic wifi in the apt, which works fine on my macbook and iphone, but see no Apple TV icon appearing on macbook screen, nor any connection happening. (nor is there anything connection w my iPhone). What gives? How can I establish a connection?

    See
    http://support.apple.com/kb/ts4215

  • How to get latest record on top of the result list

    Hi Gurus,
    How to get latest record on top of the result list when you open the record.
    saved data method in BT120H_CPL of OverView page and result list in ICCMP_INBOX.
    Regards,
    Ravi

    Hi
    Try sort descending by on fileld "changed at ".
    manipulate the sort depends on your requirement
    Regards
    Logu

  • I loos my APPLE ID, I have a new one, how can get access to data stored in the old one?

    I loos my APPLE ID, Now I have a new one, how can get access to data stored in the old one?

    Do you have the email & password of the old Apple ID?

  • How to get relationship between two  views in the  reports

    How to get relationship between two  views in the  reports, I am doing a deletion program , it is fully relates to views , how to get relationship between them in the reports

    Hi,
    Please explain your question in detail...what do you want to read ?
    If you want to know about the navigation links between the views then you can use APIs  like
    wdComponentAPI.getComponentInfo().findInWindows("windowName").getViewUsageByID("Name").getNavigationLinks();
    Iterate through the navigationLinkInfo from above collection and can read the other properties .
    I haven't tried the above , but it should work !!!
    Regards,Anilkumar

  • HT2905 Does anyone know how to find and remove duplicate items in the new itunes 11?

    I am having a hard time trying to figure out how to find and remove duplicate items under the New iTunes 11? Its not as user friendly as in previous versions. Does anyone know how to figure this out?

    As Jim said View > Show Duplicates
    or
    Option + View > Show Exact Duplicates

  • How do you remove a locked item in the trash bin

    how do you remove a locked item in the trash bin

    Hold down the option key while emtying the trash. 
    Please detail all you have done to resolve your issue.  Need this information so that the users can avoid the "been there, done that" scenario type responses.  This is to avoid repeating the troubleshooting you may have already tried.  Thank you.
     

  • Can anyone explain to how to get rid off restore session on the mozilla firefox it keeps coming up every time i click on mozilla firefox it comes up restore session why is this it is driving me nuts

    can anyone explain to me how to get rid off restore session on the mozilla firefox it keeps coming up every time i click on mozilla firefox it comes up restore session why is this i want to get rid of it it is driving me nuts

    What do you have checked in Firefox Preferences>General?
    Ciao.

  • How to get system temp dir. path on the fly ,system may be XP or Linux ??

    How to get system temp dir. path on the fly ,system may be XP or Linux ??
    please suggest solution

    The default temporary-file directory can be retrieved
    using:
    System.getProperty("java.io.tmpdir")
    Thanks a lot for u r reply this one works !!!!

  • How to get customer number and name from the SD document

    Hi All,
    Can you please let me know how to get Customer Number and Name from the SD Document?
    Thanks a lot....
    Anil

    Hi,
    It will be displayed in the SD (BIlling document) itself,  you clikc on the VF03. The customer name and number will also appear in the SO document also Tcode VA03
    regards,
    radhika
    Edited by: kolipara radhika on Jul 10, 2009 5:32 AM

  • HT4792 how to get imovie to show up in the apps on iTunes?

    i tried to follow the steps on how to get imovie projects to ipone but the imovie app doesnt show up in the apps on itunes.

    So, when you go in to System Preferences > Print & Fax > Set Up fax Modem ..., Internal Modem is NOT showing up in Fax List?
    Does Internal Modem.app exist in /Users/{shortUserName}/Library/Printers/?

Maybe you are looking for

  • Problems printing to HP Laserjet 4700dtn after upgrading to Tiger

    I just upgraded this machine to Tiger - I use a Dual 2GHz PowerPC G5. I've printed several things successfully in the two days since I upgraded, but suddenly, today, my attempts to print to the office's HP Laserjet 4700dtn have universally crashed ev

  • How to use a logical database's selection screen elements

    Hi all, I have used the logical db, pnp, in my report, however when I want to select data about a personel , ie. her name surname plans-positions, how will I join the two tables pa0001 and logical db? and the table t528t - text for plans? Thanks.

  • PDF version of presenter files - where does the attachments icon go?

    When I save my Presenter files to the server, I can link in attachments related to the presentation. http://breeze.unisa.edu.au/test11-09/ When I save the same files as a pdf - the GUI no longer has a paperclip icon to access the attachments. Is this

  • IPhoto 8 wont' find iPhoto 6 library?

    I just upgraded my mom's computer to Leopard and iLife 08. I first imported all 4,000 of her photos but when it was done it did not import the albums. The albums are critical to her organization (she just flipped). Since I have this all on a backup,

  • Incremental load not capturing data in SSIS 2012

    Hi , Iam having an issue with Oracle CDC for SSIS which is new in 2012, Developed SSIS packages with Full load and Incremental load logic to load data into ODS - STAGE - DWH. Here problem is when ever i do a full load following with an incremental lo