ListItemCollection.FindByValue(String) 메서드

정의

지정된 값을 포함하는 ListItem 속성을 갖는 컬렉션을 Value에서 검색합니다.

public:
 System::Web::UI::WebControls::ListItem ^ FindByValue(System::String ^ value);
public System.Web.UI.WebControls.ListItem FindByValue (string value);
member this.FindByValue : string -> System.Web.UI.WebControls.ListItem
Public Function FindByValue (value As String) As ListItem

매개 변수

value
String

검색할 값입니다.

반환

ListItem

value 매개 변수로 지정한 값을 포함하는 ListItem을 반환합니다.

예제

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;

  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

설명

메서드를 FindByValue 사용하여 매개 변수로 지정된 value 값이 포함된 속성이 있는 컬렉션을 ListItem Value 검색합니다. 이 메서드는 대/소문자를 구분하고 문화권을 구분하지 않는 비교를 수행합니다. 이 메서드는 부분 검색 또는 와일드카드 검색을 수행하지 않습니다. 이 조건을 null 사용하여 컬렉션에서 항목을 찾을 수 없는 경우 반환됩니다.

적용 대상

추가 정보