读书人

是高手你就点进来看看-

发布时间: 2012-03-21 13:33:14 作者: rapoo

请教高手,是高手你就点进来看看- -

HTML code
<%@ 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> 



C# code
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

热点推荐