ListItemCollection.FindByText Method

Searches the collection for a ListItem with a Text property that contains the specified text.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public:
ListItem^ FindByText (
	String^ text
)
public ListItem FindByText (
	String text
)
public function FindByText (
	text : String
) : ListItem
Not applicable.

Parameters

text

The text to search for.

Return Value

A 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 contains 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, a null reference (Nothing in Visual Basic) is returned.

No code example is currently available or this language may not be supported.
ListItem myListItem = SearchType.get_SelectedItem();
ListItem crItem = null;
String searchText = TextBox1.get_Text();
if(myListItem.get_Value().Equals("Name")) {
    if(!(TextBox1.get_Text().Equals(""))) {
        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.get_Value() + "<br />";
str = str + "the country or region name is " 
    + crItem.get_Text();

// Add the string to the label.
Label1.set_Text(str);

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: