How to access a drop down list from an ItemTemplate form

Hi @adhamfaisal,

This is a very general question! If you post something like “I’m trying to do [something], but it’s not working for me”, then anyone who wants to help you has to do a lot of work! They have to guess what you’re trying to do, then open your app, find where the problem lies, and then suggest a solution.

If you want to make it more likely that someone will help you, here are some hints. When posting on this forum, please try to:

  • Be specific about what you’re trying to do.
    For example:

    I want to add a new option to a DropDown’s items when you click a button in a RepeatingPanel.

  • Be specific about what’s not working, and what you’ve tried already.
    For example:

    I’ve written code in my ItemTemplate’s button-click handler, which updates the DropDown on Form1. But when I click the button the DropDown doesn’t get updated. I know the button_1_click function is running without errors, because I’ve tried putting a print() statement there – when I do that, and click the button, it prints in the Output panel. But it doesn’t seem to change the DropDown.

  • Maybe include a code sample of the relevant code. (In case this code isn’t enough for people to work out what’s going wrong, it’s also helpful to include a clone link for your app. You did this in your post, which is good! It’s even better if you give instructions so someone can reproduce the problem once they’ve copied the app.)
    For example:

    Here’s the button-click handler from my ItemTemplate1 form:

    def button_1_click(self, **event_args):
      """This method is called when the button is clicked"""
      text = self.button_1.text
      items = Form1.Form1().drop_down_1.items 
      items = items + [text]
    

    If you want to look at the whole app, here it is:
    Anvil | Login
    To reproduce the error, hit Run and then click any of the buttons, then check the DropDown. You should see extra options appearing, but you don’t. Can anyone help?


If you ask questions like this, then it’s much easier for us to help you – and this means it’s much more likely that you’ll get help!

For example, now that I’ve restated your problem in an easy-to-understand way, I expect one of our forum regulars will be able to answer your question before long…

4 Likes