You are using i twice, once for the table, and then again for each row.
Much better to do this:
foreach(DataTable innerTable in dsRpt.Tables)
{
foreach(DataRow row in innerTable.Rows)
{
DataRow newRow = table.NewRow();
newRow["No"] = row[3].ToString();
newRow["Question"] = row[4].ToString();
newRow[row[1].ToString() + " " + row[2].ToString()] = row[5].ToString();
table.Rows.Add(newRow);
}
}
Also, you assign tempProjectNameData to the second item in the row, then test to see if it equals that same value, which will always be true. You never use tempNumberData.
Then at the end you assign the variables again, for no reason.
/- Sam Judson : Wrox Technical Editor -/
|