This is a migrated thread and some comments may be shown as answers.

DropDownLists bind the first time but not on subsequent binding

2 Answers 33 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 13 Jul 2012, 12:42 PM
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 Answers, 1 is accepted

Sort by
0
Dean
Top achievements
Rank 1
answered on 13 Jul 2012, 07:55 PM
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
0
Greg
Top achievements
Rank 1
answered on 14 Jul 2012, 01:56 PM
Dino,

That solved it.

Thanks
Tags
DropDownList
Asked by
Greg
Top achievements
Rank 1
Answers by
Dean
Top achievements
Rank 1
Greg
Top achievements
Rank 1
Share this question
or