foreach套在for中为什么不走了呢
public void show()
{
Response.Write("show()方法");
int right_code = 0;
List<int> list = ShowMenu();
string rightSql = "select * from sys_right where right_code = "+right_code;
List<Right> rightList = new List<Right>();
DataTable rightTable = null;
for (int i = 0; i < list.Count; i++)
{
Response.Write("for循环");
right_code = list[i];
rightTable = DbHelp.ReturnDataTable( rightSql);
Response.Write("list中的值"+list[i]);
if (i<list.Count)
{
Response.Write("进入if循环了+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
foreach (DataRow rightrow in rightTable.Rows)
{
Response.Write("进入foreach循环了+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
Right rr = new Right();
rr.Right_code = Convert.ToInt32(rightrow["right_code"]);
rr.Right_parent_code = Convert.ToInt32(rightrow["right_parent_code"]);
rr.Right_text = Convert.ToString(rightrow["right_text"]);
rr.Right_url = Convert.ToString(rightrow["right_url"]);
rr.Right_type = Convert.ToString(rightrow["right_type"]);
string node = "";
string head = "";
if (rr.Right_type == "Folder")
{
head = "<h1 class=\"type\"><a href=\"javascript:void(0)\" target=\"mainFrame\">\"" + rr.Right_text + "\"</a></h1>";
}
string center = "<div class=\"content\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td><img src=\"images/menu_topline.gif\" width=\"160\" height=\"5\" alt=\"\" /></td></tr></table>";
string foot = " <ul class=\"MM\"><li><a href=\"" + rr.Right_url + "\" target=\"mainFrame\">\"" + rr.Right_text + "\"</a></li></ul>";
node = head + center + foot;
mainMenu.InnerHtml += node;
Response.Write(node);
rightList.Add(rr);
}
}
else
{
break;
}
}
}