指定した値を格納している Value プロパティを持つ ListItem をコレクション内で検索します。
Public Function FindByValue( _
ByVal value As String _) As ListItem
[C#]
public ListItem FindByValue(stringvalue);
[C++]
public: ListItem* FindByValue(String* value);
[JScript]
public function FindByValue(
value : String) : ListItem;
パラメータ
- value
検索対象の値。
戻り値
value パラメータで指定した値を格納している ListItem 。
解説
FindByValue メソッドを使用して、value パラメータで指定した値を格納している Value プロパティを持つ ListItem をコレクション内で検索します。この検索条件を使用して項目がコレクション内で見つからない場合は、 null 参照 (Visual Basic では Nothing) が返されます。
使用例
Dim myListItem As ListItem = SearchType.SelectedItem
Dim crItem As ListItem
Dim searchText As String = TextBox1.Text
If(myListItem.Value = "Name") Then
If(TextBox1.Text <> "" ) Then
Dim searchSubfirst As String = searchText.Substring(0,1)
Dim searchSubsecond As String = searchText.Substring(1)
searchText = searchSubfirst.ToUpper()+searchSubsecond.ToLower()
' Search by country or region name.
crItem = ItemCollection.FindByText(searchText)
End If
Else
'Search by country or region code.
crItem = ItemCollection.FindByValue(searchText.ToUpper())
End If
Dim str As String = "Search is successful. Match is Found.<br>"
str = str & "The results for search string '" & searchText & "' are:<br>"
str = str & "the country or region code is: " & crItem.Value & "<br>"
str = str & "the country or region name is: " & crItem.Text
' Add the string to the label.
Label1.Text = str
[C#]
ListItem myListItem = SearchType.SelectedItem;
ListItem crItem = null;
String searchText = TextBox1.Text;
if(myListItem.Value == "Name")
{
if(TextBox1.Text != "")
{
String searchSubfir = searchText.Substring(0,1);
String searchSubsec = searchText.Substring(1);
searchText = searchSubfir.ToUpper()+searchSubsec.ToLower();
// Search by country or region name.
crItem = ItemCollection.FindByText(searchText);
}
}
else
{
// Search by country or region code.
crItem = ItemCollection.FindByValue(searchText.ToUpper());
}
String str = "Search is successful. Match is Found.<br>";
str =str + "The results for search string '" + searchText + "' are:<br>";
str = str + "the country or region code is " + crItem.Value + "<br>";
str = str + "the country or region name is " + crItem.Text;
// Add the string to the label.
Label1.Text = str;
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
参照
ListItemCollection クラス | ListItemCollection メンバ | System.Web.UI.WebControls 名前空間 | FindByText | ListItem | Value