我用repeter控件显示数据
最后一列显示的是"删除"
但是这一列是通过用户的权限来判断是否显示的怎么来控制,将这一列隐藏起来

解决方案 »

  1.   


            for (int index = 0; index < lstArticle.Items.Count; index++)
            {
              //  if ((CAccount.CurUserID() != "01979") & (CAccount.CurUserID() != "00360") & (CAccount.CurUserID() != "01923"))
                //{
                  //  if (CAccount.CurUserID() != (lstArticle.Items[index].Cells[1].Text.Trim()))
                    //{
                        //((LinkButton)lstArticle.Items[index].FindControl("lnkDelete")).Visible = false;
                        //((LinkButton)lstArticle.Items[index].FindControl("lnkUpdate")).Visible = false;
                        //((LinkButton)lstArticle.Items[index].FindControl("lnkAuth")).Visible = false;
                    //}
                //}            ((LinkButton)lstArticle.Items[index].FindControl("lnkDelete")).Attributes.Add("OnClick", "javascript:DeleteConfirm();");
            }
      

  2.   

    如果要将一列隐藏,只有通过循环。
    for(int i=0;i<table1.rows.count;i++)
    {
       table.rows[i].columns[x].visible=false;//x是你想隐藏的列的号数
    }
      

  3.   

    GridView.Columns[i].Visible=false
      

  4.   

    楼上的大哥 
    我用的是 repeter 控件
    里面用的是table我想在cs文件里实现啊
    而不是用脚本实现
      

  5.   


          <asp:Repeater ID="rptTest" runat="server">  
           <ItemTemplate>
           <table>
           <tr>
           <td><%#Eval("Title") %></td>
           <td><%#Eval("Clicks") %></td>
           <td><asp:LinkButton ID="lkbDelete" runat="server" Text="删除"></asp:LinkButton></td>
           </tr>
           </table>
           </ItemTemplate>     
           </asp:Repeater>        DataSet ds = new DataSet();
            ds = csdn.GetList("Articles", "*", "");
            if (ds != null)
            {
                rptTest.DataSource = ds.Tables[0].DefaultView;
                rptTest.DataBind();
                if ("没有权限")
                {
                    for (int i = 0; i < rptTest.Items.Count; i++)
                    {
                        ((LinkButton)rptTest.Items[i].FindControl("lkbDelete")).Visible = false;
                    }
                }
            }