int id=(int)Session["userid"];
string str = ConfigurationManager.ConnectionStrings["shuju"].ConnectionString;
SqlConnection conn = new SqlConnection(str);
for (int i = id; i < i + 4; i++)
{
string sql = " select * from [user] where grade ="+i+ "";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
for (int i = id; i < i + 4; i++)
死循環了,i < i+4永遠成立
for (int i = id,j=i+4; i<j; i++)