Repeater控件ItemDataBound事件中出错,请大侠指教。在线等
页面:
后台事件:
出错:ItemDataBound事件中
根据获取的Request.QueryString["CID"]值是否为当前绑定的MenuID,进行比较。相等则设置ID为NowSubMenuClass的Literal的Text值为当前菜单的class名称.
但运行时,没有效果。
是哪里的问题呢?在线等
1
<asp:Repeater ID="CategoryDetails" runat="server" EnableViewState="false">
2
<ItemTemplate>
3
<li<asp:Literal ID="NowSubMenuClass" runat="server" Text=" class='' "></asp:Literal>>
4
<a href="<%# Eval("URL")%>"><%# Eval("MenuName")%></a>
5
</li>
6
</ItemTemplate>
7
</asp:Repeater>
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
后台事件:
1![](/Images/OutliningIndicators/None.gif)
2![](/Images/OutliningIndicators/None.gif)
3
public 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![](/Images/OutliningIndicators/InBlock.gif)
10
string PID = Request.QueryString["PID"].ToString();
11
Int64 iPID = Int64.Parse(PID);
12![](/Images/OutliningIndicators/InBlock.gif)
13
Permaisuri.Sale.Model.MenuInfo pModel = bll.Load(iPID);
14![](/Images/OutliningIndicators/InBlock.gif)
15
CategoryTitle.Text = "<a href=\"" + pModel.URL + "\">" + pModel.MenuName + "</a>";
16![](/Images/OutliningIndicators/InBlock.gif)
17
find.SetCSNull();
18
find.ParentID = iPID;
19![](/Images/OutliningIndicators/InBlock.gif)
20
List<Permaisuri.Sale.Model.MenuInfo> Menu1 = new List<MenuInfo>();
21
22
Menu1 = bll.ListEx(find, "OrderIndex");
23![](/Images/OutliningIndicators/InBlock.gif)
24
CategoryDetails.DataSource = Menu1;
25
CategoryDetails.DataBind();
26![](/Images/OutliningIndicators/InBlock.gif)
27
28![](/Images/OutliningIndicators/InBlock.gif)
29
}
30![](/Images/OutliningIndicators/InBlock.gif)
31![](/Images/OutliningIndicators/InBlock.gif)
32
protected void CategoryDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
33
{
34![](/Images/OutliningIndicators/InBlock.gif)
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![](/Images/OutliningIndicators/InBlock.gif)
45
}
46
47
}
48![](/Images/OutliningIndicators/InBlock.gif)
49
}
50![](/Images/OutliningIndicators/InBlock.gif)
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![](/Images/OutliningIndicators/InBlock.gif)
64![](/Images/OutliningIndicators/InBlock.gif)
65
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
60
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
出错:ItemDataBound事件中
根据获取的Request.QueryString["CID"]值是否为当前绑定的MenuID,进行比较。相等则设置ID为NowSubMenuClass的Literal的Text值为当前菜单的class名称.
但运行时,没有效果。
是哪里的问题呢?在线等