ListItemCollection.FindByText(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
System::Web::UI::WebControls::ListItem ^ FindByText(System::String ^ text);
public System.Web.UI.WebControls.ListItem FindByText (string text);
member this.FindByText : string -> System.Web.UI.WebControls.ListItem
Public Function FindByText (text As String) As ListItem
Parameters
- text
- String
The text to search for.
Returns
A ListItem that contains the text specified by the text
parameter.
Examples
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
Remarks
Use the FindByText method to search the collection for a ListItem with a Text property that equals text specified by the text
parameter. This method performs a case-sensitive and culture-insensitive comparison. This method does not do partial searches or wildcard searches. If an item is not found in the collection using this criteria, null
is returned.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET