Dictionary构建快速导航
Dictionary<int, string> AuthorList = new Dictionary<int, string>();
//定义一个集合,存放导航信息
AuthorList.Add(-1, "<a href=\"/user/project_manage?state=-1\" class=\"{0}\">全部项目</a>");
AuthorList.Add(0, "<a href=\"/user/project_manage?state=0\" class=\"{0}\">未审核</a>");
AuthorList.Add(1, "<a href=\"/user/project_manage?state=1\" class=\"{0}\">审核中</a>");
AuthorList.Add(2, "<a href=\"/user/project_manage?state=2\" class=\"{0}\">审核通过</a>");
AuthorList.Add(4, "<a href=\"/user/project_manage?state=4\" class=\"{0}\">审核失败</a>");
//将导航的信息追加到集合中
//循环集合,并判断当前是否选择项目,并让样式为选中状态
foreach (KeyValuePair<int, string> item in AuthorList)
{
if (state == Convert.ToInt32(item.Key))
{
str += string.Format(item.Value.ToString(), "cur");
}
else {
str += string.Format(item.Value.ToString(), "");
}
}
