<%@ Control Language="C#" AutoEventWireup="true" CodeFile="category.ascx.cs" Inherits="category" %>
<style type="text/css">
.style3
{
width: 100%;
}
</style>
<div class="sn_Menu_content indexMenu" id="SideNav">
<div class="sn_Menu_content indexMenu" id="Div1">
<table border="1" class="style3" style="border-color: #FF0000">
<tr>
<td class="style4"
style="border-width: thin; border-style: solid; border-color: #FF0000;">
<asp:Repeater ID="rFatherCategory" runat="server"
onitemdatabound="rFatherCategory_ItemDataBound">
<ItemTemplate>
<dl>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("Id") %>' />
<br />
<a href='p_list.aspx?categoryId=<%#Eval("Id") %>'
target="_blank" style="color: #FF0000; font-size: 19px; font-family: 黑体;"><%#Eval("CategoryName")%></a>
<asp:DataList ID="DataList1" runat="server" CellPadding="2" RepeatColumns="1" Font-Size="11" Width="200px">
<%-- <FooterStyle BackColor="White" ForeColor="#333333" />--%>
<%-- <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />--%>
<%-- <ItemStyle HorizontalAlign="Left" ForeColor="#333333"
BackColor="White"></ItemStyle>--%>
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 50px">
</td>
<td style="text-align: left">
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<%#Eval("Id","~/advanced_Query.aspx?Id={0}") %>' ><%# Eval("CategoryName")%></asp:LinkButton></td>
<td style="width: 30px">
</td>
</tr>
</table>
</ItemTemplate>
<HeaderTemplate>
<br />
</HeaderTemplate>
<%-- <SelectedItemStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />--%>
</asp:DataList>
<div class="sidenavlink01 sidenavchild">
<ul class="sideleft">
<h3>
<a href='p_list.aspx?categoryId=<%#Eval("Id") %>' target="_blank"><%#Eval("CategoryName") %></a></h3>
<asp:Repeater ID="rSonCategory" runat="server" onitemdatabound="rSonCategory_ItemDataBound">
<ItemTemplate>
<%if (i == 0)
{ %>
<li class="noline">
<%}
else
{ %>
<li>
<%} i++; %>
<b>
<asp:HiddenField ID="HiddenField2" runat="server" Value='<%#Eval("Id") %>' />
<asp:LinkButton ID="LinkButton2" runat="server" PostBackUrl='p_list.aspx?categoryId=<%#Eval("Id") %>'><%#Eval("category_name") %></asp:LinkButton></b>
<div>
<asp:Repeater ID="rThreeCategory" runat="server">
<ItemTemplate>
<a href='p_list.aspx?categoryId=<%#Eval("Id") %>' title='<%#Eval("category_name") %>'
target="_blank"><%#Eval("category_name") %></a>
</ItemTemplate>
</asp:Repeater>
</div>
<span class="clear"></span></li>
</ItemTemplate>
</asp:Repeater>
<%i = 0; %>
</ul>
<ul class="sideright">
<h3>
品牌推荐
<asp:LinkButton ID="LinkButton1" runat="server" ForeColor="Red" PostBackUrl='<%#Eval("Id","p_list.aspx?categoryId={0}%>") %>'>更多</asp:LinkButton></h3>
<asp:Repeater ID="rBrandList" runat="server" onitemdatabound="rBrandList_ItemDataBound">
<ItemTemplate>
<li><asp:HyperLink ID="hlBrandLink" runat="server" Target="_blank"><%#Eval("brand_name") %></asp:HyperLink></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</dl>
</ItemTemplate>
</asp:Repeater>
<br />
<br />
<asp:HyperLink ID="HyperLink2" runat="server" Text="查看全部分类"
NavigateUrl="~/advanced_Query.aspx" ForeColor="Red" />
<%-- <img alt="" class="style2" src="images/icon-024.gif" /> --%>
</td>
</tr>
</table>
</div>
</div>using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using THSC.Model;
using THSC.BLL;
using System.Collections.Generic;
using System.Reflection;public partial class category : System.Web.UI.UserControl
{
protected int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
rFatherCategory_load();
}
private void rFatherCategory_load()
{
//string where = "is_show=1 and father_id=0";
//string fieldList = "Id,category_name,is_show,father_id,order_by";
//string orderField = "order_by";
//bool orderby = true;
//DataRecordTable table = new ProductCategoryBusiness().GetList(fieldList, orderField, orderby, 1, 9, where);
//List<DataRecordTable> data = DataTableToList<DataRecordTable>(table.Table);
List<ProductCategory> prolist = new ProductCategoryBusiness().GetTops();
rFatherCategory.DataSource = prolist;
rFatherCategory.DataBind();
}
protected void rFatherCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenField hi = e.Item.FindControl("HiddenField1") as HiddenField;
DataList re = e.Item.FindControl("DataList1") as DataList;
re.DataSource = new ProductCategoryBusiness().GetTopFather(Convert.ToInt32(hi.Value));
re.DataBind();
int Id = int.Parse(DataBinder.Eval(e.Item.DataItem, "Id").ToString());
string where = "is_show=1 and father_id=" + Id + "";
string fieldList = "Id,category_name,is_show,father_id,order_by";
string orderField = "order_by";
bool orderby = true;
Repeater rSonCategory = e.Item.FindControl("rSonCategory") as Repeater;
DataRecordTable table = new ProductCategoryBusiness().GetList(fieldList, orderField, orderby, 1, 20, where);
if (rSonCategory != null)
{
rSonCategory.DataSource = table.Table;
rSonCategory.DataBind();
} Repeater rBrandList = e.Item.FindControl("rBrandList") as Repeater;
table = new ProductBrandBusiness().GetList("Id,category_id,brand_name,order_by", "order_by", true, 1, 20, "is_show=1 and category_id=" + Id);
if (rBrandList != null)
{
rBrandList.DataSource = table.Table;
rBrandList.DataBind();
}
}
protected void rSonCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
int Id = int.Parse(DataBinder.Eval(e.Item.DataItem, "Id").ToString());
string where = "is_show=1 and father_id=" + Id;
string fieldList = "Id,category_name,is_show,father_id,order_by";
string orderField = "order_by";
bool orderby = true;
Repeater rThreeCategory = e.Item.FindControl("rThreeCategory") as Repeater;
DataRecordTable table = new ProductCategoryBusiness().GetList(fieldList, orderField, orderby, 1, 20, where);
if (rThreeCategory != null)
{
rThreeCategory.DataSource = table.Table;
rThreeCategory.DataBind();
}
//Repeater re = e.Item.FindControl("Repeater1") as Repeater;
//re.DataSource = new ProductCategoryBusiness().GetType();
//re.DataBind();
}
protected void rBrandList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
string categoryId = DataBinder.Eval(e.Item.DataItem, "category_id").ToString();
string brandId = DataBinder.Eval(e.Item.DataItem, "Id").ToString();
HyperLink hlBrandLink = e.Item.FindControl("hlBrandLink") as HyperLink;
LinkButton linkbtn = e.Item.FindControl("LinkButton1") as LinkButton;
if (hlBrandLink != null && linkbtn != null)
hlBrandLink.NavigateUrl = "p_list.aspx?categoryId=" + categoryId + "&brandId=" + brandId;
linkbtn.PostBackUrl = "/~p_list.aspx?categoryId=" + categoryId + "&brandId=" + brandId;
}
}我要在Repeater里面 做出一个鼠标放上去就显示他子节点的功能,类似于京东,淘宝左侧的商品分类
解决方案 »
- 在asp.net中如何实现整个站点的全球化
- textbox的enabled=false后,怎么通过服务器端代码改变它的值?
- 求助,上传Excel表,删除错误.
- ASP.net 上传控件我设置了只能上传10M的文件 可是传大于10M的就弹出页面无法显示
- LINQ问题
- 调用exp.exe命令做数据库备份,出现process.ExitCode=3
- ASP.NET中如何让DropDownList控件既能做选择又能做输入用?
- 这段代码怎么实现不了起我的要求啊
- 在VS.NET中做网页格式时总是出现这样的一个问题谁能帮我解决一下谢谢
- 请问如何给cookie进行加密?
- ajax + Repeater中的一个取值刷新问题
- 站内搜索代码
/**
*@author readkid
*@dependence jquery 1.2
*@since 2010/1/15
*@version 1.0
*/
(function () {
//using namespace $.suning;
$.suning || ($.suning = {});
//Extends
$.suning.extend = function (subClass, superClass) {
var F = function() {};
F.prototype = superClass.prototype;
subClass.prototype = new F();
superClass.prototype.constructor = superClass;
subClass.prototype.constructor = subClass;
subClass.base = superClass.prototype;
}
})();//SideNav
$.suning.MenuNav = function() {
var timer;
if($("#SideNav").css("display") == "none"){
$(".sn_Menu").hover(function(){
clearInterval(timer);
$("#SideNav").css("display","block");
$(this).find(".sn_Menuicon").addClass("on");
$("#SideNav").find("dl").each(function(i){
$(this).mouseover(function() {
navshow(i);
});
});
function navshow(i){
$("#SideNav").find(".icon").removeClass('on').eq(i).addClass("on");
$("#SideNav").find(".sidenavchild").hide().eq(i).show();
};
},function(){
timer = setInterval(function(){
$("#SideNav").css("display","none");
},1);
$("#SideNav").find(".icon").removeClass('on');
$(this).find(".sn_Menuicon").removeClass("on");
$(this).find(".sidenavchild").hide();
});
}else{
$("#SideNav").find("dl").each(function(i){
$(this).mouseover(function(){
$(this).find(".icon").addClass("on");
$(this).find(".sidenavchild").css("display","block");
}).mouseout(function(){
$(this).find(".icon").removeClass("on");
$(this).find(".sidenavchild").css("display","none");
})
});
}
}
这个是JS ,我的问题 最后截图给你看看,只是这个不知道怎么附加图片