Here, have a look at how it can be done:
MSDN: ListControl.SelectedIndexChanged Event[
^]
Sample:
<form id="form1" runat="server">
<asp:ListBox id="ListBox1"
OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
AutoPostBack="true"
runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:ListBox>
<asp:Label id="Label1" runat="server"/>
</form>
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = "You selected " + ListBox1.SelectedItem.Text +
" with a value of $" + ListBox1.SelectedItem.Value +
".";
}