Repopulating a dropdown outside an updatepanel

三世轮回 提交于 2019-12-13 22:09:25

问题


Probably this is an ignorance of Async postbacks, so let me lob a softball out there.

I have three cascading dropdowns in an updatepanel, using these you can pick your Store->Department->Product. A fourth DDL sits outside the updatepanel, and using this you pick your competitor. Different stores match with different competitors. A gridview (also outside) then displays the join of Store->Department->Product->Competitor Price.

This works fine when you first load and if you switch to a different store that has the same competitor. But if you change the updatepanel DDLs to a store that does not share the chosen competitor and click "Display" (causing a PostBack), I get an "Invalid Postback or callback argument." If I remove the Competitor DDL and hardcode the gridview's competitor, the error goes away and I can navigate with abandon.

Why won't that fourth DDL repopulate on postback? How do I fix this problem?


回答1:


The reason is that in the latter case on change of Store->Department->Product if you are rebinding the Competitior DropDownlist then ListItems will change on the server but will not be rendered to the client because it is not inside any updatepanel and thus the Competitior DropDownlist has old values in it.

when the Postback occurs ASP.Net will not understand how these old values came and will throw "Invalid Postback or Callback argument" error.

Best way to solve this will be place your dropdownlist (and gridview) inside an updatepanel.



来源:https://stackoverflow.com/questions/8569879/repopulating-a-dropdown-outside-an-updatepanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!