<div class="menu">
<asp:Repeater id="dlFileType" runat="server"
onitemdatabound="dlFileType_ItemDataBound1"
>
<ItemTemplate>
<asp:Label ID="lblzyc1" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>
<li class="level1">
<table id="car" class="color" width="100%" border="0" style="border-bottom: 1px solid #e7e7e7; border-collapse:collapse; background-color:#ACC397">
<tr>
<td width="99%" style="color:#ffffff; font-size:13px"> <span class="module_up_down" style=" cursor:pointer" ><img src="down.gif" alt="" /></span> <%#Eval("name")%></td>
</tr>
</table>
<ul class="level2">
<asp:Repeater id="dlFileList" runat="server" onitemcommand="dlFileList_ItemCommand" onitemdatabound="dlFileList_ItemDataBound" >
<ItemTemplate>
<table class="color" width="100%" style="border-bottom: 1px solid #e7e7e7; border-collapse:collapse">
<tr>
<td width="85%"><asp:Label ID="lblzyc" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label> <%#Eval("name")%></td>
<td width="15%">
<%#GetSubString1(Eval("id").ToString()) %>
</td>
</tr>
</table>
<asp:Repeater id="dlFileList1" runat="server" >
<ItemTemplate>
<table class="color" width="100%" style="border-bottom: 1px solid #e7e7e7; border-collapse:collapse; ">
<tr>
<td width="85%"><asp:Label ID="lblzyc" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label> <%#Eval("name")%></td>
<td width="15%">
<%#GetSubString(Eval("id").ToString()) %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ul>
</li>
</ItemTemplate>
</asp:Repeater>
</div>
<style>
.level1
{
100%;
float:left;
display:inline;
}
#car
{
100%;
line-height:25px;
}
.level2
{
100%;
float:left;
}
.level2 table
{
100%;
line-height:25px;
text-align:left;
}
</style>
private void DataBind()
{
string sql = "select * from tclass where rootid=0";
DataTable dt = mingliu.myDataAdapter(sql);
dlFileType.DataSource = dt;
dlFileType.DataBind();
pg.Text = FenYe.GetPageNum(dt, dlFileType, 8);
}
private void DataBind(int type)
{
string sql = "select * from tclass where rootid=0 and id="+type+"";
DataTable dt = mingliu.myDataAdapter(sql);
dlFileType.DataSource = dt;
dlFileType.DataBind();
pg.Text = FenYe.GetPageNum(dt, dlFileType, 8);
}
public string GetSubString1(string str)
{
string ul = "";
string sql = "select * from tcontent where type=" + Convert.ToInt32(str) + "";
DataTable dt = mingliu.myDataAdapter(sql);
if (dt.Rows.Count > 0)
{
int id = Convert.ToInt32(dt.Rows[0]["id"].ToString());
if (id != 16)
{
ul += " <a href=\"ShortEdit.aspx?id=" + id + "\">修改</a> <a href=\"citymanage.aspx?id=" + id + "\">管理图片</a>";
}
}
return ul;
}
public string GetSubString(string str)
{
string ul = "";
string sql = "select * from tcontent where type=" + Convert.ToInt32(str) + "";
DataTable dt = mingliu.myDataAdapter(sql);
if (dt.Rows.Count > 0)
{
int id = Convert.ToInt32(dt.Rows[0]["id"].ToString());
ul += " <a href=\"ShortEdit.aspx?id="+id+"\">修改</a> <a href=\"citymanage.aspx?id="+id+"\">管理图片</a>";
}
return ul;
}
protected void dlFileType_ItemDataBound1(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater dataList = (Repeater)e.Item.FindControl("dlFileList");
Label lbl = (Label)e.Item.FindControl("lblzyc1");
int mainID = Convert.ToInt32(lbl.Text);
//this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + mainID.ToString() + "!')</script>");
if (mainID > 0)
{ string sql="";
//string sql = "select * from article";
// if(typ.Length>0)
//{
// sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + mainID + " and tclass.id=tcontent.type order by tcontent.id asc";
// }
// else{
//sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + mainID + " order by tcontent.id asc";
// }
sql = "select * from tclass where rootid=" + mainID + " order by id asc";
DataTable dt = mingliu.myDataAdapter(sql);
dataList.DataSource = dt;
dataList.DataBind();
}
}
}
protected void dlFileList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater dataList = (Repeater)e.Item.FindControl("dlFileList1");
Label lbl = (Label)e.Item.FindControl("lblzyc");
if (lbl.Text.Length > 0)
{
int mainID = Convert.ToInt32(lbl.Text);
//this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + mainID.ToString() + "!')</script>");
if (mainID > 0)
{
string sql = "";
//string sql = "select * from article";
// if(typ.Length>0)
//{
//sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + Convert.ToInt32(typ) + " and tclass.id=tcontent.type order by tcontent.id asc";
// }
// else{
//sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + mainID + " and tclass.id=tcontent.type order by tcontent.id asc";
// }
sql = "select * from tclass where rootid=" + mainID + " order by id asc";
DataTable dt = mingliu.myDataAdapter(sql);
dataList.DataSource = dt;
dataList.DataBind();
}
}
}
}
protected void dlFileList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int id = Convert.ToInt32(e.CommandArgument);
string sql = "delete from tclass where id=" + id + "";
mingliu.myCommand(sql);
this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功!')</script>");
DataBind();
}
}