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 40 | Next

Joydip Kanjilal

"ASP.NET Data Presentation Controls Essentials"

Items.Add("Joydip");
ListBox1.Items.Add("Douglas");
ListBox1.Items.Add("Jini");
ListBox1.Items.Add("Piku");
ListBox1.Items.Add("Rama");
ListBox1.Items.Add("Amal");
ListBox1.Items.Add("Indronil");
} }
Now, the List???ox control is populated with data. The following figure displays the
ListBox control populated with data at runtime.
Working with List Controls in ASP.NET
[ 38 ]
Selecting One or More List Items
Now, let us see how to select one or more list items from the ListBox control. The
following figure displays the list items that have been selected from a List???ox control
in a Label control on click of a Button.
This section discusses how to accomplish the above. You can select one of more list
items from a ListBox. Drag-and-drop a Button control and a Label control onto your
web form. In the Click event of the Button, write the following code to retrieve the
selected text from the ListBox control in a single selection mode and display it in the
Label control once the Button control is clicked.
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = ListBox1.SelectedItem.Text;
}
As you can see in the above code snippet, the SelectionMode property or a ListBox
control having an ID of ListBox1, is set to "Single", implying that we can select only
one List Item from the control at any point in time.


Pages:
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6