Sapna
Sapna

Reputation: 53

Accessing Data from Data table using for loop

I want to get data from data table using for loop. i tried as belows but not working. please help me

String GetBelowDataWeekly = "Select EmployeeID from v_Et_EmployeeProfile where DivisionName=N'" + DivisionName + "' COLLATE Latin1_General_100_CI_AS and PositionName=N'Officer'COLLATE Latin1_General_100_CI_AS union all Select EmployeeID from v_Et_EmployeeProfile where DivisionName=N'" + DivisionName + "' COLLATE Latin1_General_100_CI_AS and DepartmentName= N'None' COLLATE Latin1_General_100_CI_AS";
SqlDataAdapter adaptGetBelowDataWeekly = new SqlDataAdapter(GetBelowDataWeekly, DBcon.con);
DataTable dtGetBelowDataWeekly = new DataTable();
adaptGetBelowDataWeekly.Fill(dtGetBelowDataWeekly);
for (int i = 0; i < dtGetBelowDataWeekly.Rows.Count; i++)
{
    Response.write(dtGetBelowDataWeekly.Rows[i]);
}

Upvotes: 1

Views: 1611

Answers (1)

wablab
wablab

Reputation: 1733

You need to access the first column of the Rows[i]. The first column contains the integer value you're looking for. So:

Response.write((int)dtGetBelowDataWeekly.Rows[i][0]);

Upvotes: 2

Related Questions