残疾人的DropDownList不保留在回发选定值 [英] disabled dropdownlist does not keep selected value on postback

查看:146
本文介绍了残疾人的DropDownList不保留在回发选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个怪异的行为有一个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

<一个href=\"http://stackoverflow.com/questions/8687598/how-to-get-selected-value-of-disabled-dropdown-in-c-sharp\">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不保留在回发选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆