DropDownLists bind the first time but not on subsequent binding

3 posts, 0 answers
  1. Greg
    Greg avatar
    7 posts
    Member since:
    Apr 2012

    Posted 13 Jul 2012 Link to this post

    Using the dropdownlist (3) in a mobile web app, using a tabstrip and 3 views. The dropdowns are populated based on data returned after a user enters a value in a textbox. The onblur calls a function which fetches data via Ajax and then populates the dropdowns and a few textboxes. The ajax calls returns all the data needed, there is not a separate call for each dropdown.

    My problem is that it always works correctly on the first binding but never on subsequent bindings. I've confirmed that the subsequent ajax calls are returning data and I've also wired up an alert message to the dataBound event for each dropdown and that also fires.

    After seeing this problem I thought that maybe clearing the dropdowns before binding might solve the problem but it does not, still have the same issue. I assume there is one small piece I am missing but not sure what that might be.

    I don't think this is a browser related issue because it happens in Chrome, Safari, IE, Safari for iPhone and the Android browser.
  2. Dean
    Dean avatar
    1 posts
    Member since:
    Feb 2012

    Posted 13 Jul 2012 Link to this post

    Greg,

    Try put this code after you bind the list - for some reason, on subsequent calls it can have a display: none attribute which causes your problem.
             $("#yourControl").parent()[0].style.removeAttribute("display"); 

    HTH
    Dino
  3. Greg
    Greg avatar
    7 posts
    Member since:
    Apr 2012

    Posted 14 Jul 2012 Link to this post

    Dino,

    That solved it.

    Thanks
Back to Top