如果为前登录用户“操作”那栏显示“--”,反之则如下图

解决方案 »

  1.   

    这是前台代码:
     <%# getAction(Eval("Sw_Id").ToString())%>这是cs
        public static string getAction(string id)
        { 
            string re="";
           if (id==System.Web.HttpContext.Current.Session["UserId"].ToString())
           {
              re= "--";
           }
           else
           {
            re= "<a href='UserEdit.aspx?id="+id+"'>编辑</a>&nbsp;&nbsp;这里要怎么写 ";
           }
            return re;
        }
      

  2.   

    不知道你用什么绑定的 但是你可以直接这样
    举个例子 你用linkbutton控件
    你可以在表格(比如gridview等的rowcreate事件里判断然后enabled或者visabled掉按钮就可以了 )
    不用在后台输出成html到前台吧
      

  3.   

        public static string getAction(string id)
        { 
            string re="";
           if (id==System.Web.HttpContext.Current.Session["UserId"].ToString())
           {
              re= "--";
           }
           else
           {
            re= "<a href='UserEdit.aspx?id="+id+"'>编辑</a>&nbsp;&nbsp;<a href='this.aspx?del="+id+"'>编辑</a> ";
           }
            return re;
        }
    //传给本页,本页在bind前进行delete动作
      

  4.   


    "<a href='UserEdit.aspx?id="+id+"'>编辑</a>&nbsp;&nbsp;<a href='UserDel.aspx?id="+id+"'>删除</a>"//UserDel.aspx.cs 处理
      

  5.   


        public static string getAction(string id)
        { 
            string re="";
           if (id==System.Web.HttpContext.Current.Session["UserId"].ToString())
           {
              re= "--";
           }
           else
           {
            re= "<a href='UserEdit.aspx?id="+id+"'>编辑</a>&nbsp;&nbsp;<a href='this.aspx?del="+id+"' style='color:gray'>删除</a> ";
           }
            return re;
        }
    //this.aspx指本页,去判断Request.Querystring["del"]
    //传给本页,本页在bind前进行delete动作
      

  6.   

     <%# getAction(Eval("Sw_Id"),Eval("用户名"))%>
    public string getAction(object swid,object userName)
    {
    if(Session["UserId"].ToString().Equels(userName.toString()))
    {
    return "---";
    }
    else
    {return "..."; }
    }