我想给Repater循环出来的linkButton中的某一个值当我点击的时候添加样式,然后点击另外一个的时候样式转到另一个Linkbutton上。已经弄了1天了 还是没有找到方法。用OnClientClicK也不能绑定ID号 会报错。后台还控制着选中以后下面刷新数据。。应该怎么做 下面是我的代码
<li><span class="c1">游戏类型</span><span>:</span> <div style="float: left; width: 264px;"> <asp:Repeater ID="GameKind" runat="server" OnItemCommand="GameKind_ItemCommand"> <ItemTemplate> <asp:LinkButton ID="Button1" runat="server" CommandName="Select1" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>'/><span>|</span> </ItemTemplate> </asp:Repeater> </div> </li> <li><span class="c1">游戏特征</span><span>:</span> <asp:Repeater ID="GameFeature" runat="server" OnItemCommand="GameFeature_ItemCommand"> <ItemTemplate> <asp:LinkButton ID="Button3" runat="server" CommandName="Select3" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>' /><span>|</span> </ItemTemplate> </asp:Repeater> </li> </div> <div class="fr"> <li><span class="c1">游戏品质</span><span>:</span> <asp:Repeater ID="GameQuality" runat="server" OnItemCommand="GameQuality_ItemCommand"> <ItemTemplate> <asp:LinkButton ID="Button2" runat="server" CommandName="Select2" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>'/><span>|</span> </ItemTemplate> </asp:Repeater> </li> <li><span class="c1">游戏人群</span><span>:</span> <asp:Repeater ID="GameCrowd" runat="server" OnItemCommand="GameCrowd_ItemCommand"> <ItemTemplate> <asp:LinkButton ID="Button4" runat="server" CommandName="Select4" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>' /><span>|</span> </ItemTemplate> </asp:Repeater> </li>
后台代码:
#region 选择游戏栏目绑定 protected void GameKind_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Select1") { KindNum = e.CommandArgument.ToString(); Pagination(KindNum, QualityNum, FeatureNum, CrowdNum, sign); //LinkButton lBtn1 = e.Item.FindControl("Button1") as LinkButton; //lBtn1.CssClass = "selected"; } } protected void GameQuality_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Select2") { QualityNum = e.CommandArgument.ToString(); Pagination(KindNum, QualityNum, FeatureNum, CrowdNum, sign); //LinkButton lBtn2 = e.Item.FindControl("Button2") as LinkButton; //lBtn2.CssClass = "selected"; } } protected void GameFeature_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Select3") { FeatureNum = e.CommandArgument.ToString(); Pagination(KindNum, QualityNum, FeatureNum, CrowdNum, sign); //LinkButton lBtn3 = e.Item.FindControl("Button3") as LinkButton; //lBtn3.CssClass = "selected"; } } protected void GameCrowd_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Select4") { CrowdNum = e.CommandArgument.ToString(); Pagination(KindNum, QualityNum, FeatureNum, CrowdNum, sign); //LinkButton lBtn4 = e.Item.FindControl("Button4") as LinkButton; //lBtn4.CssClass = "selected"; } } #endregion }
有没有高手愿意帮我下。本人新手园豆不多。。。谢谢~~