C#
protected void btnSel_Click(object sender, EventArgs e)
{
var selItems = from ListItem li in ListBox1.Items
where li.Selected == true
select li.Text;
Response.Write("Selected Item(s): ");
foreach (var item in selItems)
{
Response.Write(item.ToString() + "");
}
}
VB.NET
Protected Sub btnSel_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim selItems = _
From li As ListItem In ListBox1.Items _
Where li.Selected = True _
Select li.Text
Response.Write("Selected Item(s): ")
For Each item In selItems
Response.Write(item.ToString() & "")
Next item
End Sub
On clicking the Button, the selected items are fetched as shown below:
image
No comments:
Post a Comment