Reputation: 7
trying to get a specific item in a list box which will then load new web page getting error saying listbox doesnt have 'findString' method?
Am i possibly missing a using ?
protected void lstVideos_SelectedIndexChanged(object sender, EventArgs e)
{
// Get the currently selected item in the ListBox.
string curItem = lstVideos.SelectedItem.ToString();
// Find the string in lstVideos.
int index = lstVideos.FindString(curItem);
// If the item was not found in lstVideos display a message box, otherwise select it in lstVideos.
if (index == 1)
{
}
Upvotes: 0
Views: 555
Reputation: 21825
The code you are trying is for windows form ListBox and not for asp.net ListBox
control. You can simply use SelectedIndex property to get the selected index:-
int index = lstVideos.SelectedIndex;
Upvotes: 1