title: hide a specfic row in DataGrid asp.net using VB
body: <p>This seems pretty easy to anyone but i cannot search on how to hide a speficic row in DataGrid(Not GridView) in asp.net using vb. When i was searching, i only saw on how to hide a column using   DataGrid1.Columns(0).Visible = False. I tried hiding it using ItemDataBound event but it hides the whole column along with its headercolumntext. </p>
  
  <p>My aim is to search data with using a textbox where Date = textboxdate.text. This is easy to do in sql but i cannot revise the query because it is in a stored procedure.</p>
  
  <p>This is my current code:</p>
  
  <pre><code> If txtAdmDate.Text &lt;&gt; "" Then
  
          If Not String.Equals(txtAdmDate.Text, e.Item.Cells(0).Text) Then
              e.Item.Cells(0).Visible = False
          End If
  
      End If
  </code></pre>
  
  <p>I want to make something like this.</p>
  
  <pre><code>    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
      If txtAdmDate.Text &lt;&gt; "" Then
          If DataGrid1.Row(0).text &lt;&gt; txtAdmDate.Text Then
              DataGrid1.Row(0).Visible = False
          End If
      End If
  End Sub
  </code></pre>
  
  <p>ASPX page:</p>
  
  <pre><code>Search By Date:
   &lt;asp:TextBox ID="txtAdmDate" runat="server"&gt;&lt;/asp:TextBox&gt;
   &lt;asp:Button ID="btnSearch" runat="server" Text="Refresh / Search" /&gt;
  &lt;br /&gt;
  &lt;asp:DataGrid ID="DataGrid1" runat="server" CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"&gt;
      &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
      &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
      &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
      &lt;Columns&gt;
          &lt;asp:BoundColumn DataField="Admission Date" HeaderText="Admission Date"&gt;&lt;/asp:BoundColumn&gt;
          &lt;asp:BoundColumn DataField="Hospital #" HeaderText="Hosp. #"&gt;&lt;/asp:BoundColumn&gt;
          &lt;asp:BoundColumn DataField="Admission #" HeaderText="Reg. #"&gt;&lt;/asp:BoundColumn&gt;
          &lt;asp:BoundColumn DataField="Patient Name" HeaderText="Patient Name" Visible="false"&gt;&lt;/asp:BoundColumn&gt;
          &lt;asp:ButtonColumn DataTextField="Patient Name"  HeaderText="Patient Name" CommandName="Select"&gt;&lt;/asp:ButtonColumn&gt;
          &lt;asp:BoundColumn DataField="Discharged Date" HeaderText="Discharged Date"&gt;&lt;/asp:BoundColumn&gt;
          &lt;asp:BoundColumn DataField="Billing Date" HeaderText="Billing Date"&gt;&lt;/asp:BoundColumn&gt;
      &lt;/Columns&gt;
  &lt;/asp:DataGrid&gt;
  </code></pre>