后台:
/// <summary>
/// 2016年1月23日 动态加载首页
/// </summary>
/// <param name="spID"></param>
/// <returns></returns>
public string Menu()
{
string connStr = AppConfiguration.CoreConnectionString;
string sql = @"select * from MenuCode where MenuID in(SELECT A.RightID FROM CodeGroupRight A,OperatorRole B,RoleRight C
WHERE A.CodeGroupID in(2001,2002,2003,2004,2005,2006,2007,2008
,2009,2010,2011,2012,2013,2014,2015,2016,2017) AND B.OperatorID = "+this.OpLoginInfo.OperatorID+" AND B.RoleID = C.RoleID AND A.RightID = C.RightID GROUP BY A.RightID,B.ApplicationTypeIDs) and vc2Type='sp' ";
DataSet ds = SqlHelper.ExecuteDataset(connStr, CommandType.Text, sql);
StringBuilder sb = new StringBuilder();
sb.Append("<table id=\"table1\">\n");
sb.Append("<tr><th></th><th></th></tr>\n");
int trid = 11;
int NextTrid = 21;
int trid2 = 12;
int NextTrid2 = 22;
int count = ds.Tables[0].Rows.Count + 1; ;
for (int i = 0; i <= ds.Tables[0].Rows.Count; i= i+2)
{
int j = 0;
string name2 = string.Empty;
string HtmlUrl2 = string.Empty;
if (i < ds.Tables[0].Rows.Count)
{
j = i + 1;
name2 = ds.Tables[0].Rows[i]["MenuName"].ToString();
HtmlUrl2 = ds.Tables[0].Rows[i]["vc2Url"].ToString();
}
string name = ds.Tables[0].Rows[j]["MenuName"].ToString();
string HtmlUrl = ds.Tables[0].Rows[j]["vc2Url"].ToString();
if (j == 0)
{
sb.Append("<tr ><td runat=\"server\" height=\"30\" width=\"27\" id=\"tr" + trid + "\"><IMG height=\"27\" src=\"images/list.gif\" width=\"27\"></td><td runat=\"server\" width=\"160\" align=\"left\" id=\"tr" + NextTrid + "\"><A class=\"boldtitle\" href=" + HtmlUrl + ">" + name + "</A></td> </tr>\n");
}
else
{
sb.Append("<tr ><td runat=\"server\" height=\"30\" width=\"27\" id=\"tr" + trid + "\"><IMG height=\"27\" src=\"images/list.gif\" width=\"27\"></td><td runat=\"server\" width=\"160\" align=\"left\" id=\"tr" + NextTrid + "\"><A class=\"boldtitle\" href=" + HtmlUrl + ">" + name + "</A></td> <td runat=\"server\" height=\"30\" width=\"27\" id=\"tr" + trid2 + "\"><IMG height=\"27\" src=\"images/list.gif\" width=\"27\"></td><td runat=\"server\" width=\"160\" align=\"left\" id=\"tr" + NextTrid2 + "\"><A class=\"boldtitle\" href=" + HtmlUrl2 + ">" + name2 + "</A></td></tr>\n");
}
trid = trid + 2;
NextTrid = NextTrid + 2;
trid2 = trid2 + 2;
NextTrid2 = NextTrid2 + 2;
}
sb.Append("</table >\n");
return sb.ToString();
}
前台:
<%=Menu()%>