I have a list box that has a list of roles defined. List of roles are binded to the list box in page load event. I am trying to retrieve the selected role from the text box but i am getting a null reference error even though one of the item is selected. below is the code that gives me null reference.
I even tried using the code below and all i get is null value. seems like it not selecting any thing form the list box.
Does any one have any idea what is going on??
Thanks in advance.
Code:
String role = lstRole.SelectedItem.ToString();
Code:
Label1.Text = role;
I even tried using the code below and all i get is null value. seems like it not selecting any thing form the list box.
Code:
String role = lstRole.SelectedValue;
Thanks in advance.
Comment