title: Hide Repeater Element with condition
body: <p>I want to hide the repeater element that already added in table but now I faced some problem which is even I done for the comparison condition the repeater will also show out the overall content based on the table. Here is my coding part. Hope will know the mistake that i made. </p>
  
  <p>Designer code :</p>
  
  <pre><code>&lt;script language="C#" runat="server"&gt;
  protected void ItemDataBound(object sender, RepeaterItemEventArgs e)
      {
          String personID = "";
          try
          {
              MySql.Data.MySqlClient.MySqlConnection connStr = new MySql.Data.MySqlClient.MySqlConnection();
              connStr.ConnectionString = "Server = localhost; Database = healthlivin; Uid = root; Pwd = khei92;";
              String searchPerson = "SELECT PersonIDB from contactFriend WHERE PersonID = @id";
              MySql.Data.MySqlClient.MySqlCommand cmdSearch = new MySql.Data.MySqlClient.MySqlCommand(searchPerson, connStr);
              connStr.Open();
              cmdSearch.Parameters.AddWithValue("@id", "M000001");
  
  
              MySql.Data.MySqlClient.MySqlDataReader dtrRead2 = cmdSearch.ExecuteReader();
  
              if (dtrRead2.Read())
              {
                  personID = (String)dtrRead2["PersonIDB"];
              }
  
              dtrRead2.Close();
              connStr.Close();                
          }
          catch (Exception ex)
          {
              System.Windows.Forms.MessageBox.Show(ex.ToString());
          }
  
          if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
          {
              Label lblID = (Label)e.Item.FindControl("lblID");
              string s = lblID.Text;
  
              if (s == personID)
              {
                  lblID.Visible = false;
                  e.Item.FindControl("photoImage").Visible = false;
                  e.Item.FindControl("lblName").Visible = false;
                  e.Item.FindControl("deleter").Visible = false;
                  e.Item.FindControl("lblEmail").Visible = false;
              }
              else
              {
                  lblID.Visible = true;
                  e.Item.FindControl("photoImage").Visible = true;
                  e.Item.FindControl("lblName").Visible = true;
                  e.Item.FindControl("deleter").Visible = true;
                  e.Item.FindControl("lblEmail").Visible = true;
              }
          }
  
      }
    &lt;/script&gt;
  
  &lt;asp:Repeater ID="friendRepeater" runat="server" OnItemDataBound = "ItemDataBound"&gt;
      &lt;HeaderTemplate&gt;
      &lt;table cellpadding="0" cellspacing="0"&gt;
      &lt;/HeaderTemplate&gt;
  
  
      &lt;ItemTemplate&gt;
      &lt;tr&gt;
         &lt;td&gt;
         &lt;div style=" padding-left:180px;"&gt; 
             &lt;div id="leftHandPost" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;"&gt;
                &lt;div id="childLeft" style=" padding-left:5px;"&gt;
                   &lt;div id="photo"  style=" border: thin solid black; width:100px;height:100px;"&gt;
                     &lt;asp:Image id="photoImage" runat="server" ImageUrl='&lt;%# String.Concat("Images/", Eval("Picture")) %&gt;' Width="100px" Height="100px" /&gt;
                   &lt;/div&gt;
                 &lt;/div&gt;&lt;!--childLeft--&gt;
              &lt;/div&gt;&lt;!--leftHandPost--&gt;
              &lt;/div&gt;
          &lt;/td&gt;
  
                          &lt;td&gt;
                              &lt;div id="rightHandPost" style=" float:right; padding-right:260px;"&gt;
                                  &lt;div id="childRight" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;"&gt;
                                      &lt;strong&gt;&lt;asp:Label id="lblName" runat="server"&gt;&lt;%# Eval("PersonName") %&gt;&lt;/asp:Label&gt;&lt;/strong&gt;&lt;br /&gt;
                                      &lt;div style=" float:right; padding-right:10px;"&gt;
  
                                      &lt;asp:ImageButton id="deleter" ImageUrl="App_Themes/Health/images/blue/Add.png" CausesValidation="False" runat="server"
                          AlternateText="Add" ImageAlign="absmiddle" BorderStyle="None" Width="21" Height="21"
                           OnCommand="add" OnClientClick="return confirm('Are you sure you want to add this?');" CommandArgument='&lt;%# DataBinder.Eval(Container.DataItem, "PersonID") %&gt;' /&gt;
                           &lt;/div&gt;&lt;br /&gt;
                                      &lt;asp:Label id="lblID" runat="server"&gt;&lt;%# Eval("PersonID") %&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                                      &lt;asp:Label id="lblEmail" runat="server"&gt;&lt;%# Eval("Email") %&gt;&lt;/asp:Label&gt;
                                  &lt;/div&gt;&lt;!--childRight--&gt;
                              &lt;/div&gt;&lt;!--rightHandPost--&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
      &lt;/ItemTemplate&gt;
  
      &lt;AlternatingItemTemplate&gt;
      &lt;tr&gt;
         &lt;td&gt;
         &lt;div style=" padding-left:180px;"&gt; 
             &lt;div id="Div1" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;"&gt;
                &lt;div id="Div2" style="padding-left:5px;"&gt;
                   &lt;div id="Div3"  style=" border: thin solid black; width:100px;height:100px;"&gt;
                     &lt;asp:Image id="photoImage" runat="server" ImageUrl='&lt;%# String.Concat("Images/", Eval("Picture")) %&gt;' Width="100px" Height="100px" /&gt;
                   &lt;/div&gt;
                 &lt;/div&gt;&lt;!--childLeft--&gt;
              &lt;/div&gt;&lt;!--leftHandPost--&gt;
          &lt;/div&gt;
          &lt;/td&gt;
  
                          &lt;td&gt;
                              &lt;div id="Div4" style=" float:right; padding-right:260px;"&gt;
                                  &lt;div id="Div5" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;"&gt;
                                      &lt;strong&gt;&lt;asp:Label id="lblName" runat="server"&gt;&lt;%# Eval("PersonName")%&gt;&lt;/asp:Label&gt;&lt;/strong&gt;
                                      &lt;div style=" float:right; padding-right:10px;"&gt;
                                      &lt;asp:ImageButton id="deleter" ImageUrl="App_Themes/Health/images/blue/Add.png" CausesValidation="False" runat="server"
                          AlternateText="Add" ImageAlign="absmiddle" BorderStyle="None" Width="21" Height="21"
                           OnCommand="add" OnClientClick="return confirm('Are you sure you want to add this?');" CommandArgument='&lt;%# DataBinder.Eval(Container.DataItem, "PersonID") %&gt;' /&gt;
                           &lt;/div&gt;&lt;br /&gt;
                                      &lt;br /&gt;
                                      &lt;asp:Label id="lblID" runat="server"&gt;&lt;%# Eval("PersonID") %&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                                      &lt;asp:Label id="lblEmail" runat="server"&gt;&lt;%# Eval("Email") %&gt;&lt;/asp:Label&gt;
                                  &lt;/div&gt;&lt;!--childRight--&gt;
                              &lt;/div&gt;&lt;!--rightHandPost--&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
      &lt;/AlternatingItemTemplate&gt;
  
      &lt;FooterTemplate&gt;
      &lt;/table&gt;
      &lt;/FooterTemplate&gt;
  
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>For the PageLoad :</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
              try
              {
                  MySqlConnection connStr = new MySqlConnection();
                  connStr.ConnectionString = "Server = localhost; Database = healthlivin; Uid = root; Pwd = khei92;";
                  String searchOverall = "SELECT PersonID, PersonName, Email, Picture FROM Person";
                  MySqlCommand cmdSearch = new MySqlCommand(searchOverall, connStr);
                  connStr.Open();
  
                  MySqlDataReader dtrRead2 = cmdSearch.ExecuteReader();
                  friendRepeater.DataSource = dtrRead2;
                  friendRepeater.DataBind();
                  dtrRead2.Close();
                  dtrRead2 = null;
  
                  connStr.Close();
  
              }
              catch (Exception ex)
              {
                  //MessageBox.Show(ex.ToString());
              }            
          }             
      }
  </code></pre>