ListItemCollection.FindByText Method (String)
.NET Framework (current version)
Namespace:
System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Return to top
Assembly: System.Web (in System.Web.dll)
Parameters
- text
-
Type:
System.String
The text to search for.
Return Value
Type: System.Web.UI.WebControls.ListItemA ListItem that contains the text specified by the text parameter.
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.
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;
.NET Framework
Available since 1.1
Available since 1.1
Show: