2017-01-31 9 views
0

リストボックス内の特定の項目を取得しようとすると、新しいWebページがロードされる listbox does notに 'findString'メソッドがありますか?リストボックスのfindstringメソッドが機能していませんか? c#

私はおそらく使用していますか?

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) 
    { 

    } 
+0

コードをコンパイルしますか?あなたは例外をどこで正確に得ますか?例外全体を投稿してください –

答えて

1

あなたがしようとしているコードは、asp.net ListBox制御のためのWindowsフォームListBoxないためです。選択したインデックスを取得するには、SelectedIndexプロパティを使用します。 -

int index = lstVideos.SelectedIndex; 
関連する問題