属性selecteditem只是radiobuttonlist的readonly [英] Property selecteditem is readonly for radiobuttonlist
问题描述
我有错误属性selectitem是readonly当我动态创建这样的单选按钮列表:
Dim DDL As 新 DropDownList
Dim RBL As 新 RadioButtonList
Dim CBL 作为 新 CheckBoxList
DDL.ID = DDL _& SelectedCategory& _& SubAssy& _& ProductType
RBL.ID = RBL _& SelectedCategory& _& SubAssy& _& ProductType
CBL.ID = CBL _& SelectedCategory& _& SubAssy& _& ProductType
如果 ProductType = 常规 或(CategorySelected = KC 2.1(没有织带的卷收器) 和 ProductType = KC2.1 或 ProductType = Webbing)或
(CategorySelected = KC 2.1安全带) 和 ProductType = < span class =code-string> KC2.1)然后
DDL.Visible = False
RBL.Visible = Fals e
CBL.Visible = False
DDL.SelectedItem = True
RBL.SelectedItem = True
CBL.SelectedItem = True
结束 如果
在以下3行代码中:
DDL.SelectedItem = True
RBL.SelectedItem = True
CBL.SelectedItem = True
显示错误。我必须使用RadioButtonList或DropDownList或CheckBoxList创建一个用户选择项目的表,但我希望某个按钮具有预先选择的值并且不显示。当我阅读所有选中的按钮时,我希望这样。
我尝试过:
我尝试不在我的表格中显示,但我希望在我选择时将其选中
文档说明SelectedItem [ ^ ]如果要以编程方式设置所选项目,则需要使用 SelectedIndex [ ^ ]属性Quote:获取列表控件中索引最低的所选项目。
Quote:获取或设置列表中所选项目的最低序号索引。
您使用的值True
表示您正在尝试访问控制列表的特定成员,在这种情况下,您需要指定哪一个。如果您正在尝试这样做,您可能会发现此链接很有用 c# - 以编程方式检查复选框列表中的项目,其中文本等于我想要的内容 - Stack Overflow [ ^ ](这是在C#但原则是相同的)或这一个保存用户&#CheckBoxList选项并从保存的数据中重新填充CheckBoxList [ ^ ]
I have the error Property selecteditem is readonly when I dynamically create a radio button list like this:
Dim DDL As New DropDownList
Dim RBL As New RadioButtonList
Dim CBL As New CheckBoxList
DDL.ID = "DDL_" & SelectedCategory & "_" & SubAssy & "_" & ProductType
RBL.ID = "RBL_" & SelectedCategory & "_" & SubAssy & "_" & ProductType
CBL.ID = "CBL_" & SelectedCategory & "_" & SubAssy & "_" & ProductType
If ProductType = "General" Or (CategorySelected = "KC 2.1 (retractor without webbing)" And ProductType = "KC2.1" Or ProductType = "Webbing") Or
(CategorySelected = "KC 2.1 Seatbelt)" And ProductType = "KC2.1") Then
DDL.Visible = False
RBL.Visible = False
CBL.Visible = False
DDL.SelectedItem = True
RBL.SelectedItem = True
CBL.SelectedItem = True
End If
On these 3 lines of code:
DDL.SelectedItem = True
RBL.SelectedItem = True
CBL.SelectedItem = True
the error is displayed. I have to create a table with RadioButtonList or DropDownList or CheckBoxList where the user select items, but I want some button to have a pre-selected value and doesn't display. I want that for when I read all buttons selected.
What I have tried:
I try to not display in my table, but i want to be selected for when i red them
The documentation states that SelectedItem[^]Quote:Gets the selected item with the lowest index in the list control.
If you want to programmatically set the selected item you need to use the SelectedIndex[^] property which
Quote:Gets or sets the lowest ordinal index of the selected items in the list.
The fact that you are using values ofTrue
implies that you are trying to access a specific member of the control list, in which case you need to specify which one. You might find this link useful if that is what you are trying to do c# - Programatically Check an Item in Checkboxlist where text is equal to what i want - Stack Overflow[^] (It's in C# but the principles are the same) or this one Saving a user's CheckBoxList selection and re-populating the CheckBoxList from saved data[^]
这篇关于属性selecteditem只是radiobuttonlist的readonly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!