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 09:06 AM UTC

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 9, 2003 04:47 AM UTC

Thank you! It may be done using Datatable.Select

Loader.
Up arrow icon