The ASP.Net RadioButtonList control provides the functionality to display radio button controls as ListItems in the Web form. You can select the one radio button item of RadioButtonList control by changing the inactive state of the selected item. The selected item of RadioButtonList returns the Boolean type result as true or false that determines the checked state of an individual list item based on the C# code logic applied on it. If the list item is in checked state then it returns true and if it is in unchecked state then the radio button rendered as list item returns false. You can use the ASP.Net RadioButtonList web server control to get the user input as a single selection under a specific group of multiple multually exclusive options. Some simple examples of RadioButtonList control are displaying a list of titles prefixes for name such as "Mr", "Ms", "Er" or "Dr." etc. Users can select only one Title as their Name prefix. Similarly you can display the gender options using RadioButtonList control such as "Male" or "Female" and user can choose one. The ASP.Net RadioButtonList control provides the inbuilt functionality to display the radio button list items as multually exclusive set of choices that allow the users to select only one item among the multiple options.
The ASP.Net RadioButtonList control consists of following properties that are commonly used to get or set the values or user input. There are two sets of properties below; the first set includes the properties that enable you to get or set the values of list items of RadioButtonList and the second set includes the properties that enable you to customize its appearance:
AppendDataBoundItems: It allows you to add the list items of RadioButtonList statically along with the data-bound list items retrieved from any data source. It is a Boolean type property that accepts value as true or false for allowing or disallowing the append feature of list items.
AutoPostBack: It is also a Boolean type property that enables the control to send the web page to PostBack when user clicks the radio button list item to select it.
DataMember: It accepts the name of one of the data table stored in the data source, if there is a collection of data tables in it. For example using SQL queries or stored procedures you can retrieve data in the form of multiple data tables that can be stored into the DataSet class object. This DataSet object can be used to bind the data to different types of Data-bound controls. The DataMember property enables you to specify the name of the table that you want to bind with the data-bound control.
DataSource: This property allows you to specify the name of the data source dynamically.
DataSourceID: It accepts the ID of the DataSource control used to retrieve the data from the database.
DataTextField: It accepts the name of the Field/Column of the data table stored in the datasource object that you want to display as the text content of the list item.
DataTextFormatString: It allows you to format the text property of the RadioButtonList item. For example you can use {0:C} to format the numeric value as currency. There are different types of formats such as {0:X}, {0:E}, {0:N}, {0:C}. You can learn about these formats from this tutorial: ASP.Net C# String Format Function
DataValueField: It accepts the name of the field of the data table stored in the datasource object that you want to set as the value attribute of each list item. This value part does not appear as text content.
0 comments:
Post a Comment