I want to create several items for radiobuttonlist by myself, the item has text and value properties. How to do it in c#/asp.net? Thanks in advance.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
You can use a DataTable for the data source (or other bindable source), and bind the DataTable to the RadioButton list. Use DataTextField and DataValueField properties to specify which column is used for text and which is used for the value.
You can create own DataSource which will be automatically displayed in the VisualStudio toolbox along with other standard controls, if you really need such kind of data source try out following:
}
ASPX:
You can us a Dictionary object to store the key/values and bind it to the RadioButtonList like so:
Or you can also add the items to the RadioButtonList Items collection like so: