动态生成菜单,cs代码如下:
private void bindTwo()
{
string sqlWhere = "companyid = 'TEXFACTOR'";
string directorys = string.Empty;
//最大的table
string path1 = string.Format("<table border='0' class='main_table' cellspacing='0' cellpadding='0'>");
path1 += string.Format("<tbody><tr><td class='box_width_td_left'>");
path1 += string.Format("<table border='0' class='box_width_left' cellspacing='0' cellpadding='0'>");
path1 += string.Format("<tbody><tr><td></td></tr>");
path1 += string.Format("<tr><td>");
path1 += string.Format("<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBoxHeading_table'>");
path1 += string.Format("<tbody><tr><td class='infoBoxHeading_b'>"); //Categories
path1 += string.Format("<table cellpadding='0' cellspacing='0' border='0' class='infoBoxHeading_r'>");
path1 += string.Format("<tbody><tr>");
path1 += string.Format("<td class='infoBoxHeading_l'>");
path1 += string.Format("<table cellpadding='0' cellspacing='0' border='0' class='infoBoxHeading_tl'>");
path1 += string.Format("<tbody><tr>");
path1 += string.Format("<td class='infoBoxHeading_tr'>");
path1 += string.Format("<table cellpadding='0' cellspacing='0' border='0' class='infoBoxHeading_bl'>");
path1 += string.Format("<tbody><tr><td class='infoBoxHeading_td infoBoxHeading_br'>Categories</td></tr></tbody></table>");
path1 += string.Format("</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>");
path1 += string.Format("<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBox_table'>");
path1 += string.Format("<tbody><tr><td class='infoBox_td'>");
path1 += string.Format("<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBoxContents2_table'>");
path1 += string.Format("<tbody><tr><td class='boxText'>");
path1 += string.Format("<ul class='categories'>"); ds = fa.GetList(sqlWhere);
foreach(DataRow i in ds.Tables[0].Rows)
{
string ItemFamily = i["ItemFamilyID"].ToString();
string ItemFamilyID = i["ItemFamilyID"].ToString(); string imgName = "next-actd.gif"; //string urljpg = "url(" + "img/" + imgName + ")";
string urljpg = "" + "img/" + imgName + ""; string url = "AddToCar.aspx";[/color[color=#FF0000]]//在这里我该如何根据条件来连接到不同的页面?
path1 += string.Format("<li class='bg_list'><a href='" + url + "'><span id='{2}' name='{1}' >{1}</span></a></li>", "", ItemFamily, ItemFamilyID); string strWhere = "companyid = 'TEXFACTOR'";
ds = child.GetList(strWhere);
if(ds.Tables[0].Rows.Count > 0)
{
foreach(DataRow k in ds.Tables[0].Rows)
{
if(ItemFamilyID == k["ItemFamilyID"].ToString())
{
string ItemCategory = k["ItemCategoryID"].ToString();
string ItemCategoryID = k["ItemFamilyID"].ToString();
//path1 += string.Format("<li class='bg_list'><div><a href='#'><span id='{2}' name='{1}' onclick='loaddirectory(this.id,this.title)'>{1}</span></a></div></li>", "", ItemCategory, ItemCategoryID);
path1 += string.Format("<li class='bg_list'><div><a href='#'><span id='{2}' name='{1}'>{1}</span></a></div></li>", "", ItemCategory, ItemCategoryID);
}
}
}
}
path1 += string.Format("</ul>");
path1 += string.Format("</td></tr></tbody></table>");
path1 += string.Format("</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>"); directorys += path1;
Literal1.Text = directorys;
}
private void bindTwo()
{
string sqlWhere = "companyid = 'TEXFACTOR'";
string directorys = string.Empty;
//最大的table
string path1 = string.Format("<table border='0' class='main_table' cellspacing='0' cellpadding='0'>");
path1 += string.Format("<tbody><tr><td class='box_width_td_left'>");
path1 += string.Format("<table border='0' class='box_width_left' cellspacing='0' cellpadding='0'>");
path1 += string.Format("<tbody><tr><td></td></tr>");
path1 += string.Format("<tr><td>");
path1 += string.Format("<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBoxHeading_table'>");
path1 += string.Format("<tbody><tr><td class='infoBoxHeading_b'>"); //Categories
path1 += string.Format("<table cellpadding='0' cellspacing='0' border='0' class='infoBoxHeading_r'>");
path1 += string.Format("<tbody><tr>");
path1 += string.Format("<td class='infoBoxHeading_l'>");
path1 += string.Format("<table cellpadding='0' cellspacing='0' border='0' class='infoBoxHeading_tl'>");
path1 += string.Format("<tbody><tr>");
path1 += string.Format("<td class='infoBoxHeading_tr'>");
path1 += string.Format("<table cellpadding='0' cellspacing='0' border='0' class='infoBoxHeading_bl'>");
path1 += string.Format("<tbody><tr><td class='infoBoxHeading_td infoBoxHeading_br'>Categories</td></tr></tbody></table>");
path1 += string.Format("</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>");
path1 += string.Format("<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBox_table'>");
path1 += string.Format("<tbody><tr><td class='infoBox_td'>");
path1 += string.Format("<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBoxContents2_table'>");
path1 += string.Format("<tbody><tr><td class='boxText'>");
path1 += string.Format("<ul class='categories'>"); ds = fa.GetList(sqlWhere);
foreach(DataRow i in ds.Tables[0].Rows)
{
string ItemFamily = i["ItemFamilyID"].ToString();
string ItemFamilyID = i["ItemFamilyID"].ToString(); string imgName = "next-actd.gif"; //string urljpg = "url(" + "img/" + imgName + ")";
string urljpg = "" + "img/" + imgName + ""; string url = "AddToCar.aspx";[/color[color=#FF0000]]//在这里我该如何根据条件来连接到不同的页面?
path1 += string.Format("<li class='bg_list'><a href='" + url + "'><span id='{2}' name='{1}' >{1}</span></a></li>", "", ItemFamily, ItemFamilyID); string strWhere = "companyid = 'TEXFACTOR'";
ds = child.GetList(strWhere);
if(ds.Tables[0].Rows.Count > 0)
{
foreach(DataRow k in ds.Tables[0].Rows)
{
if(ItemFamilyID == k["ItemFamilyID"].ToString())
{
string ItemCategory = k["ItemCategoryID"].ToString();
string ItemCategoryID = k["ItemFamilyID"].ToString();
//path1 += string.Format("<li class='bg_list'><div><a href='#'><span id='{2}' name='{1}' onclick='loaddirectory(this.id,this.title)'>{1}</span></a></div></li>", "", ItemCategory, ItemCategoryID);
path1 += string.Format("<li class='bg_list'><div><a href='#'><span id='{2}' name='{1}'>{1}</span></a></div></li>", "", ItemCategory, ItemCategoryID);
}
}
}
}
path1 += string.Format("</ul>");
path1 += string.Format("</td></tr></tbody></table>");
path1 += string.Format("</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>"); directorys += path1;
Literal1.Text = directorys;
}
解决方案 »
- 如何将多个安装包打成一个安装包
- 我的PagedDataSource与AspnetPager配合分页不起作用,求哥哥们帮我看看
- 怎么用Oracle写DAL层里面拼装sql的语句啊
- 请教大师RodioButtonList的用法
- Excel文件删除问题
- datatable的统计问题,在线等,马上结帖
- 请指点:为什么session在有的页面访问得到,而在有的页面访问不到
- ACCESS里的自动编号问题
- 怎样将从数据库中读取的大量文本显示.net网页上固定的<tr><td>。。。</td></tr>中
- 如何把一个DataGrid中的数据写入一个datatable中,然后再从datatable读取出来?急!!谢谢
- 求救关于Page_PreInit函数
- ASP.NET单点登录
switch(类型) case 拼接连接的页面
是啊,是从数据库中读取产品类型,动态读取类型来做菜单的啊,就是:大类,大类下的小类,就是这么分的。然后连接到不同产品类型的datalist页面显示数据
不根据数据表中的那个连接路径的字段,仅仅只是根据读取的产品类型来分类,之后并显示在右边的datalist里面,能实现吗?该怎么实现?
不用datalist也可以实现。
思路供你参考!
大家可以去看看
<tr>
<td class="boxText" style="height: 6px;">
<asp:LinkButton ID="LinkButton1" CommandName="Chilid" CommandArgument='<%# Eval("ItemCategoryID")%>' runat="server">
<%#Eval("ItemCategoryID")%>
</asp:LinkButton>