我想做一个和QQ评论差不多功能的界面就是看到别人的评论你可以支持也可以点反对,点了支持或者反对后边上的数字就会加1然后这一条评就不能论点击了,除非关闭页面再打开.
代码如下:前台aspx代码
<asp:Repeater ID="Repeater2" runat="server" onitemcommand="Repeater2_ItemCommand">
              <ItemTemplate>
                         <tr>
              <td class="gray14" colspan="2" height="60" valign="top" style=" padding-left:8px;" ><%#DataBinder.Eval(Container.DataItem, "Comments_Content")%></td>
            </tr>
            <tr>
              <td align="right" colspan="2" height="40" class="usname"><asp:HiddenField ID="hiddCommentsID" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"Comments_ID") %>'/>
              <asp:LinkButton runat="server" ID="BtnSupport" CommandName="BtnSupport">支持</asp:LinkButton>[<%#DataBinder.Eval(Container.DataItem, "Comments_Support")%>]   
              &nbsp;&nbsp;&nbsp;&nbsp;<asp:LinkButton ID="BtnOppose" CommandName="BtnOppose" runat="server" >反对</asp:LinkButton>[<%#DataBinder.Eval(Container.DataItem, "Comments_Oppose")%>]</td>
            </tr>
                          </ItemTemplate>
              </asp:Repeater> 后台CS代码:
       protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            HiddenField CommentsID = (HiddenField)e.Item.FindControl("hiddCommentsID");
            LinkButton lb;
            switch (e.CommandName.ToLower())
            {
                case "btnsupport":     //支持
                    objCommentInfo = objcomment.GetInfo(int.Parse(CommentsID.Value.Trim()));
                    objCommentInfo.Comments_Support++;
                    objcomment.update(objCommentInfo);
                    DateBin(); 
                    break;                case "btnoppose":   //反对
                    objCommentInfo = objcomment.GetInfo(int.Parse(CommentsID.Value.Trim()));
                    objCommentInfo.Comments_Oppose++;
                    objcomment.update(objCommentInfo);
                    DateBin();
                    break;
            }
            
        }我现在能实现点击后增加支持和反对人数,就是不能让他点后变灰色,不可再点了!!有什么办法吗?

解决方案 »

  1.   

    public bool b
    {
    get{return (bool)ViewState["b"];}
    set{ViewState["b"]=value;}
    }
    设置标识
    LinkButton lbtn=e.Item.FindControl( "BtnSupport") as LinkButton; 
    if(lbtn!=null){} 
      

  2.   

    代码如下:
        protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            LinkButton lb=(LinkButton)e.CommandSource;
            int Index = ((RepeaterItem)(lb.NamingContainer)).ItemIndex;//获得行号
            ((LinkButton)Repeater2.Items[Index].FindControl("btnoppose")).Enabled = false;
            ((LinkButton)Repeater2.Items[Index].FindControl("btnsupport")).Enabled = false;
    .........................
    }
      

  3.   

    koukoujiayi 厉害.就是我行号得不到呀,不然就有办法了!
      

  4.   

    如何点一个Repeater中的其他值已经灰色的值如何如何恢复正常??