Method name expected

  • Thread starter Thread starter Vishu
  • Start date Start date
V

Vishu

I m getting this error "Mehtod name expected" in my following code.

protected int GetSelectedIndex(string CID)
{
DataTable dt = ddlDataSet.Tables["Jobs"];
for(int iLoop = 0; iLoop <= dt.Rows.Count - 1; iLoop++)
{
if(Int32.Parse(CID) == Int32.Parse(dt.Rows[iLoop]("job_id")))
{
return iLoop;
}
}
}

at dt.Rows[iLoop].
Please help me solving this problem.

Thanks in Advance.
 
Vishu said:
I m getting this error "Mehtod name expected" in my following code.

protected int GetSelectedIndex(string CID)
{
DataTable dt = ddlDataSet.Tables["Jobs"];
for(int iLoop = 0; iLoop <= dt.Rows.Count - 1; iLoop++)
{
if(Int32.Parse(CID) == Int32.Parse(dt.Rows[iLoop]("job_id")))
{
return iLoop;
}
}
}

at dt.Rows[iLoop].
Please help me solving this problem.

Yes - you're useing ("job_id") as if it's a method parameter, but
you're not calling a method. Perhaps you meant to use the DataRow
indexer? If so, it should be ["job_id"].
 
By applying the above change.. Now i m getting this error.

"The best overloaded method match for 'int.Parse(string)' has some
invalid arguments
 
Vishu said:
By applying the above change.. Now i m getting this error.

"The best overloaded method match for 'int.Parse(string)' has some
invalid arguments

Right - you'll need to cast the result of the indexer to a string, as
the indexer just provides an object.

I would suggest parsing CID just once though, before you start the
loop. Also, if the column job_id is always going to contain numeric
data, why not make it a numeric column to start with, rather than
parsing string data all the time?
 
Thanks Jon.
Right - you'll need to cast the result of the indexer to a string, as
the indexer just provides an object.

I would suggest parsing CID just once though, before you start the
loop. Also, if the column job_id is always going to contain numeric
data, why not make it a numeric column to start with, rather than
parsing string data all the time?
 
Back
Top