A
Andy Sutorius
Hi,
I am attempting to convert this vb function to csharp but I am getting stuck
on the if statement dt.Rows(iLoop)("FAQCategoryID")). The compiler says
"method name expected" and underlines dt.Rows[iLoop]. I don't understand.
Thanks for your help.
Function GetSelIndex(CatID as String) as Integer
Dim iLoop as Integer
'Loop through each row in the DataSet
Dim dt as DataTable = ddlDataSet.Tables("Categories")
For iLoop = 0 to dt.Rows.Count - 1
If Int32.Parse(CatID) = Int32.Parse(dt.Rows(iLoop)("FAQCategoryID"))
then
Return iLoop
End If
Next iLoop
End Function
public int GetSelIndex(string CatID)
{
int iLoop;
// Loop through each row in the DataSet
DataTable dt = ddlDataSet.Tables["Categories"];
int rowCount = dt.Rows.Count-1;
for (iLoop=0; rowCount <= iLoop; iLoop++)
if (Int32.Parse(CatID) = Int32.Parse(dt.Rows[iLoop]("id")))
{
return iLoop;
}
}
I am attempting to convert this vb function to csharp but I am getting stuck
on the if statement dt.Rows(iLoop)("FAQCategoryID")). The compiler says
"method name expected" and underlines dt.Rows[iLoop]. I don't understand.
Thanks for your help.
Function GetSelIndex(CatID as String) as Integer
Dim iLoop as Integer
'Loop through each row in the DataSet
Dim dt as DataTable = ddlDataSet.Tables("Categories")
For iLoop = 0 to dt.Rows.Count - 1
If Int32.Parse(CatID) = Int32.Parse(dt.Rows(iLoop)("FAQCategoryID"))
then
Return iLoop
End If
Next iLoop
End Function
public int GetSelIndex(string CatID)
{
int iLoop;
// Loop through each row in the DataSet
DataTable dt = ddlDataSet.Tables["Categories"];
int rowCount = dt.Rows.Count-1;
for (iLoop=0; rowCount <= iLoop; iLoop++)
if (Int32.Parse(CatID) = Int32.Parse(dt.Rows[iLoop]("id")))
{
return iLoop;
}
}