如果我理解正确,您可以像这样计算读者阅读量。然后当计数适合您时,您可以添加不同的内容:
int count = 0;
if (dReader.HasRows) {
while (dReader.Read()) {
if(count == 1) //add special row
gameweekList.Text += "something special " + dReader["gameweekID"].ToString();
else
gameweekList.Text += "<div class=\"item\"><h4>Gameweek " +
(dReader["gameweekID"].ToString()) + "</h4></div>";
count++;
}
} else {
gameweekList.Text = "Error Finding Gameweeks";
}
dReader.Close();
conn.Close();
但是,如果您想同时读取当前和后续读取,您应该先读取一次,然后开始循环读取,如下所示:
if (dReader.HasRows) {
string previousRead = string.Empty;
dReader.Read();
previousRead = dReader["gameweekID"].ToString();
while (dReader.Read()) {
//use current and previous read
//dReader["gameweekID"].ToString()
//previousRead
//update previousRead for the next read
previousRead = dReader["gameweekID"].ToString();
}
} else {
gameweekList.Text = "Error Finding Gameweeks";
}
dReader.Close();
conn.Close();