We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataView.Find() - how to search an item with wildcard?

DataView.Find() look for an item exactly: MyDataView.Sort="FirstName"; strFind="Nick" int nFind = MyDataView.Find(strFind); If strFind will be like "Nic" - search failed What to do?

2 Replies

AD Administrator Syncfusion Team January 8, 2003 04:06 AM

You can cheat and use a RowFilter on the view to look up all rows that start with a string, and then do an eact search. This does cause a flicker as the DataTable is filtered and quickly restored.
private void button1_Click(object sender, System.EventArgs e)
{
	DataView dv = this.dataSet11.Customers.DefaultView;
	dv.RowFilter = "[ContactName] LIKE 'B*'";
	string s = "";
	if(dv.Count > 0)
	{
		s = dv[0]["ContactName"].ToString();
	}
	dv.RowFilter = "";
	if( s != "")
	{
		int i = this.dataSet11.Customers.DefaultView.Find(s);
		Console.WriteLine(i.ToString());
	}
}


SP Sergey P January 8, 2003 11:47 PM

Thank you! It may be done using Datatable.Select

Loader.
Live Chat Icon For mobile
Up arrow icon