我得到一个怪异的行为有一个DropDownList,当我触发回发。
I'm getting a weird behavior with a dropdownlist when I trigger a postback.
如果DropDownList中被启用,所选值保持在回发后相同。
If the dropdownlist is enabled, the selected value remains the same after a postback.
然而,如果DropDownList的被禁止(经由当用户蜱一个复选框一个JavaScript),则所选择的值复位为在列表中的第一项。
However, if the dropdownlist is disabled (via a javascript when user ticks a checkbox), then the selected value is reset to the first item in the list.
怎么来的?
推荐答案您需要手动查找值(可能其存储在另一场左右),然后自己将其设置在code后面。这是因为如果一个控制禁用,该值将不会被调回断绝。
you need to look up the value manually (probably store it in another field or so), and then set it yourself in the code behind. This is because if a control is disabled, the value would not be posted back to the sever.
看看这个问题,并通过帕文指的是第一个答案
Check out this question, and refer to the first answer by Pavan
how在C#以获取所选残疾人下拉值
how to get selected value of Disabled dropdown in c#
如果你想在读第二个下拉列表中的值(一个失效) 服务器,你将永远无法读取更新后的值,数据监守 在禁用的控件将不会从客户端回发到服务器
If you are trying to read the value of 2nd dropdown (disabled one) at server, you will never be able to read the updated value, becuase data in disabled controls will not be posted back to server from client
更多推荐
残疾人的DropDownList不保留在回发选定值
发布评论