Hi,
I'm trying to locate a certain row in my datagridview, using textbox _textchanged event. Grid is populated with table having 2 columns as primary keys. With one column I have no problem, but using 2 columns I'm having exception .
private void dfSponsorname_TextChanged(object sender, EventArgs e)
{
try
{
DataTable tb = ds.Tables["Sponsors"];
int intRow;
DataColumn[] dcolPk = new DataColumn[2];
DataColumn column;
column = new DataColumn();
column = tb.Columns["SPONSOR_CODE"];
dcolPk[0] = column;
column = new DataColumn();
column = tb.Columns["SUB_CODE"];
dcolPk[1] = column;
tb.PrimaryKey = dcolPk;
tb.DefaultView.Sort = "SPONSOR_CODE,SUB_CODE";
// This is where I get exc." Expecting 2 keys but 1 received 1. "
//To search I have to use sponsor_name column not
//key columns
if (tb.Rows.Contains(dfSponsorname.Text.Trim()))
{
// At least one row matches primary key
rowFound = tb.Rows.Find(dfSponsorname.Text);
I appreciate any help.
snky