Hi there,

I have this method to search a DataView:

public int FindIndex(string columnName, object key)
{
index = -1;
foreach (DataRowView drv in table.DefaultView)
{
if (drv[columnName].Equals(key))
{
index = i;
break;
}

i++;
}
return index;
}

So far this does not work:

int i = FindIndex("IDFIELD", textBox1.Text); <= I get a -1

However, this does work ok:

string search = textBox1.Text;
int i = SearchIndex("IDFIELD", Convert.ToInt32(textBox1.Text));

In this case I get the correct index.

Any ideas?

Regards,

-Benton

Re: DataRowView and objects don't match? by Cor

Cor
Thu Feb 02 00:37:48 CST 2006

Benton,

Why don't you use the DataView.Find, in my idea does it the same (look at
the more simple non overloaded version as well)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic2.asp

I hope this helps,

Cor