Repeater隐藏html标签

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
        {
            if (string.IsNullOrEmpty((e.Item.FindControl("Label1") as Label).Text.Trim()))
            {
                //e.Item.FindControl("name").Controls.Clear();
                (e.Item.FindControl("name") as Control).Visible = false;
            }
            if (string.IsNullOrEmpty((e.Item.FindControl("Label10") as Label).Text.Trim()))
            {
                //(e.Item.FindControl("dianhua") as HtmlGenericControl).Visible = false;
                //e.Item.FindControl("dianhua").Controls.Clear();
                (e.Item.FindControl("dianhua") as Control).Visible = false;
            }
            if (string.IsNullOrEmpty((e.Item.FindControl("Label13") as Label).Text.Trim()))
            {
                (e.Item.FindControl("fox") as Control).Visible = false;
                //e.Item.FindControl("fox").Controls.Clear();
                //(e.Item.FindControl("fox") as HtmlGenericControl).Visible = false;
            }
            if (string.IsNullOrEmpty((e.Item.FindControl("Label11") as Label).Text.Trim()))
            {
                (e.Item.FindControl("shouji") as Control).Visible = false;
                //e.Item.FindControl("shouji").Controls.Clear();
                //(e.Item.FindControl("shouji") as HtmlGenericControl).Visible = false;
            }
            if (string.IsNullOrEmpty((e.Item.FindControl("Label12") as Label).Text.Trim()))
            {
                (e.Item.FindControl("email") as Control).Visible = false;
                //e.Item.FindControl("email").Controls.Clear();
                //(e.Item.FindControl("email") as HtmlGenericControl).Visible = false;
            }
            if (string.IsNullOrEmpty((e.Item.FindControl("Label23") as Label).Text.Trim()))
            {
                (e.Item.FindControl("add") as Control).Visible = false;
                //e.Item.FindControl("add").Controls.Clear();
                //(e.Item.FindControl("add") as HtmlGenericControl).Visible = false;
            }
            if (string.IsNullOrEmpty((e.Item.FindControl("Label21") as Label).Text.Trim()))
            {
                (e.Item.FindControl("zip") as Control).Visible = false;
                //e.Item.FindControl("zip").Controls.Clear();
                //(e.Item.FindControl("zip") as HtmlGenericControl).Visible = false;
            }

     HtmlTableCell tdView = e.Item.FindControl("tdView") as HtmlTableCell;
          tdView.Visible = false;
          if (Request["GroupId"]!=null)
          {
              tdView.Visible = true;
          }
        }
    }

你可能感兴趣的:(html标签)