简体   繁体   English

ASP.NET C#如何在嵌套用户控件中的Telerik RadComboBox中重新建立EmptyMessage?

[英]ASP.NET C# How to re-establish EmptyMessage in Telerik RadComboBox in nested User Control?

I have the following scenario: 我有以下情况:

  • the main aspx page aspx主页面
  • a user control inside that aspx.page, let's call this parent_user_control aspx.page中的一个用户控件,我们称其为parent_user_control
  • two RadComboBox, with only numbers on them. 两个RadComboBox,上面只有数字。
  • The first one, RadComboBox1, for example, when the user chooses 2, it will dynamically generate 2 user controls, let's call them child_user_control_1 第一个,例如RadComboBox1,当用户选择2时,它将动态生成2个用户控件,我们称它们为child_user_control_1
  • The second one, RadComboBox2, for example when the user chooses 1, it will dynamically generate 1 user control, let's call it child_user_control_2. 第二个是RadComboBox2,例如,当用户选择1时,它将动态生成1个用户控件,我们将其称为child_user_control_2。
  • child_user_control_2, has another RadComboBox, called RadComboBox_2_1, again with numbers only, that dynamically generates another user control, called grandchild_user_control. child_user_control_2具有另一个RadComboBox,称为RadComboBox_2_1,同样仅带有数字,可动态生成另一个用户控件,称为grandchild_user_control。
  • grandchild_user_control has a RadComboBox called RadComboBox_grandchild, with an EmptyMessage="Please select", and only numbers, but the numbers must match RadComboBox1, as in, when 2 was chosen, only options 1 through 2 should appear in this RadComboBox_grandchild. grandchild_user_control有一个名为RadComboBox_grandchild的RadComboBox,带有EmptyMessage =“ Please select”,并且只有数字,但是数字必须与RadComboBox1匹配,例如,当选择2时,此RadComboBox_grandchild中仅出现选项1到2。 If the value from RadComboBox1 changes to 5, then the range of values in RadComboBox_grandchild should change to 1 through 5. Same if it decreases from 2 to 1, only the value 1 should be available. 如果RadComboBox1中的值更改为5,则RadComboBox_grandchild中的值范围应更改为1到5。如果值从2减少到1,则相同,只有值1可用。
  • I properly handled the recreation of dynamic user controls, so all values persist, and the values in RadComboBox_grandchild get properly updated. 我正确地处理了动态用户控件的重新创建,因此所有值都保持不变,并且RadComboBox_grandchild中的值得到了正确更新。

Here is the problem: 这是问题所在:

When I change the value to a smaller number, say from 3 to 1, and I have, for example, the value 2 already chosen in RadComboBox_grandchild, the list gets updated, and in the code_behind the values change correctly (as in selectedIndex is -1, selectedItem is null, etc.) BUT, I do not see "Please select", I still see the value "2", even though it is no longer on the list. 当我将值更改为较小的数字(例如,从3更改为1)时,例如,我已经在RadComboBox_grandchild中选择了值2,该列表将被更新,并且在code_behind中,值正确更改(如selectedIndex为- 1,selectedItem为null,等等。)但是,我不再看到“请选择”,尽管仍然不在列表中,但我仍然看到了值“ 2”。

How can I avoid this? 如何避免这种情况? How can I make it show the EmptyMessage "Please select" again? 如何使其再次显示EmptyMessage“请选择”? I tried the ClearSelection method, but it didn't do anything because it already is without a selection. 我尝试了ClearSelection方法,但是它没有做任何事情,因为它已经没有选择。 It seems to me that the mechanism used to persist the values from the previous postback is forcefully persisting a value that no longer exists. 在我看来,用于持久保留上次回发中的值的机制正在强制持久化一个不再存在的值。

It seems to me that the mechanism used to persist the values from the previous postback is forcefully persisting a value that no longer exists. 在我看来,用于持久保留上次回发中的值的机制正在强制持久化一个不再存在的值。

It is; 它是; you can turn EnableViewState property for control on or off. 您可以打开或关闭EnableViewState属性以进行控制。

I suppose you need to clear properties Text and/or SelectedValue of your Telerik.Web.UI.RadComboBox instance that persists outdated value. 我想您需要清除持久化过时值的Telerik.Web.UI.RadComboBox实例的属性Text和/或SelectedValue。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM