• Repeater控件ItemDataBound事件中出错,请大侠指教。在线等


    页面:
    1                            <asp:Repeater ID="CategoryDetails" runat="server" EnableViewState="false">
    2                            <ItemTemplate>
    3                                <li<asp:Literal ID="NowSubMenuClass" runat="server" Text=" class='' "></asp:Literal>>
    4                                    <href="<%# Eval("URL")%>"><%Eval("MenuName")%></a> 
    5                                </li>
    6                            </ItemTemplate>
    7                            </asp:Repeater> 

    后台事件:
     1
     2
     3public partial class Control_SubMenu : System.Web.UI.UserControl
     4{
     5    Permaisuri.Sale.BLL.Menu bll = new Permaisuri.Sale.BLL.Menu();
     6    Permaisuri.Sale.Model.MenuInfo find = new MenuInfo();
     7    protected void Page_Load(object sender, EventArgs e)
     8    {
     9
    10        string PID = Request.QueryString["PID"].ToString();
    11        Int64 iPID = Int64.Parse(PID);
    12
    13        Permaisuri.Sale.Model.MenuInfo pModel = bll.Load(iPID);
    14
    15        CategoryTitle.Text = "<a href=\"" + pModel.URL + "\">" + pModel.MenuName + "</a>";
    16
    17        find.SetCSNull();
    18        find.ParentID = iPID;
    19
    20        List<Permaisuri.Sale.Model.MenuInfo> Menu1 = new List<MenuInfo>();
    21        
    22        Menu1 = bll.ListEx(find, "OrderIndex");
    23
    24        CategoryDetails.DataSource = Menu1;
    25        CategoryDetails.DataBind();
    26
    27   
    28
    29    }

    30
    31
    32    protected void CategoryDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
    33    {
    34
    35        if (e.Item.ItemType == ListItemType.Item)
    36        {
    37            Permaisuri.Sale.Model.MenuInfo ss = (Permaisuri.Sale.Model.MenuInfo)e.Item.DataItem;
    38            Int64 SubMenuID = ss.MenuID;
    39            Literal NowSubMenu = (Literal)e.Item.FindControl("NowSubMenuClass");
    40            //判断是否为当前子菜单
    41            if (IsNowSubMenu(SubMenuID))
    42            {
    43                NowSubMenu.Text = " class='nowsubmenu' ";
    44
    45            }
         
    46        
    47        }

    48
    49    }

    50
    51    private bool IsNowSubMenu(Int64 NowCID)
    52    {
    53        string CID = Request.QueryString["CID"];
    54        if (!(CID == "" || CID == null))
    55        {
    56            if (Int64.Parse(CID) == NowCID)
    57            {
    58                return true;
    59            }

    60        }

    61        return false;
    62    }

    63
    64
    65}



    出错:ItemDataBound事件中
        根据获取的Request.QueryString["CID"]值是否为当前绑定的MenuID,进行比较。相等则设置ID为NowSubMenuClassLiteral的Text值为当前菜单的class名称.

    但运行时,没有效果。

    是哪里的问题呢?在线等




  • 相关阅读:
    JavaScript 本地对象、内置对象、宿主对象
    数据交换格式
    网页设计之内容、结构、表现分离
    Web前端浏览器兼容初探
    javascript call()与apply()
    天气API
    display:inline,display:inline-block,display:block 区别
    javascript sort()与reverse()
    The Primo ScholarRank Technology: Bringing the Most Relevant Results to the Top of the List
    IOS ——OC—— NSMutableDictionary的使用总结
  • 原文地址:https://www.cnblogs.com/liuweitoo/p/922294.html
Copyright © 2020-2023  润新知