SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 62 | Next

Joydip Kanjilal

"ASP.NET Data Presentation Controls Essentials"


Note that the first list item, that is, the list item at index 0 is selected. This section
would discuss how we can add list items to this control.
Chapter 2
[ 59 ]
The following code snippet illustrates how you can create a RadioButtonList
control in your .aspx page populated with list items that contain static data:






Note that the Selected property of the control is used to set the default selected list
item from among the collection of list items in the control.
You can also append the list items programmatically. Refer to the following code
snippet given:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rbListDept.Items.Add(new ListItem("IT"));
rbListDept.Items.Add(new ListItem("Sales"));
rbListDept.Items.Add(new ListItem("Admin"));
rbListDept.Items.Add(new ListItem("HR"));
rbListDept.Items[0].Selected = true;
}
}
Selecting a List Item
Drag-and-drop a button and a Label control onto your web form. In the Click event
of the Button control, write the following code to retrieve the text of the selected list
item in the RadioButtonList control.


Pages:
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6