title: Removing duplicate rows in GridView
body: <p>I have three <code>GridView</code> that for some  reason has first duplicate data for the first three column> its not an error because thats how i want it to be. </p>
  
  <p>I want the grid to leave blank where duplicate in the above two columns <code>Client Name</code> and <code>Branch</code> . I loop through my cells and set them to empty on <code>Databound</code> as below.</p>
  
  <pre><code>protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      string oldValue = string.Empty;
      string newValue = string.Empty;
      //  for (int count = 0; count &lt; gvList.Rows.Count; count++)
      for (int j = 0; j &lt; 2; j++)
      {
          for (int count = 0; count &lt; gvList.Rows.Count; count++)
          {
              oldValue = gvList.Rows[count].Cells[j].Text;
              if (oldValue == newValue)
              {
                  gvList.Rows[count].Cells[j].Text = string.Empty;
              }
              newValue = oldValue;
          }
      }
  }
  </code></pre>
  
  <p><a href="https://imgur.com/9QZe0Fr" rel="nofollow noreferrer"><img src="https://i.imgur.com/9QZe0Fr.png" title="Hosted by imgur.com"/></a></p>
  
  <p>After running i get the result below. The grid do what i want to for a row and omit teh row proceeding it. I am confused. Please better alternative would be appreciated. </p>
  
  <p>My second question is , i have another grid also that duplicate few rows. I applied the same method and <code>Dispose()</code> where duplicate but nothing change. I use </p>
  
  <pre><code>gridview.rows[].cells.clear/disposed()` 
  </code></pre>
  
  <p>My girdview is as below.</p>
  
  <pre><code> &lt;asp:GridView ID="gvList" runat="server" AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true" OnSorting="gvList_sorting" 
                     DataKeyNames="contactID" OnPageIndexChanging="gvList_PageIndexChanging" OnRowCancelingEdit="gvList_RowCancelingEdit" 
                     OnRowDeleting="gvList_RowDeleting"  OnRowEditing="gvList_RowEditing" OnRowUpdating="gvList_RowUpdating" OnRowDataBound="gvList_RowDataBound"
                 EnableModelValidation="True" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True"&gt;
  
  
                         &lt;Columns&gt; 
  
  
                                  &lt;asp:BoundField DataField="cname" HeaderText="Client Name" ReadOnly="true" SortExpression="cname"  /&gt;
                                  &lt;asp:BoundField DataField="bname" HeaderText="Branch" ReadOnly="true" SortExpression="bname" /&gt;
                                  &lt;asp:BoundField DataField="name" HeaderText="Contact " SortExpression="name" /&gt;
                                   &lt;asp:BoundField DataField="type" HeaderText="Type " SortExpression="type" ReadOnly="true" /&gt;
                                    &lt;asp:BoundField DataField="description" HeaderText="Description " SortExpression="description" ReadOnly="true" /&gt;
  
  
  
                                  &lt;asp:CommandField ShowEditButton="true" /&gt;
                                   &lt;asp:TemplateField&gt;
                                 &lt;ItemTemplate&gt;
                                            &lt;asp:linkbutton id="ContactlnkDelete" runat="server" text="Delete" causesvalidation="false" commandname="Delete" commandargument="ID"&gt;
                                              &lt;/asp:linkbutton&gt;
  
  
                                              &lt;cc1:modalpopupextender id="lnkDelete_ModalPopupExtender2" runat="server" cancelcontrolid="ButtonDeleteCancel" okcontrolid="ButtonDeleleOkay" 
                                                  targetcontrolid="ContactlnkDelete" popupcontrolid="DivDeleteConfirmation" backgroundcssclass="ModalPopupBG"&gt;
                                             &lt;/cc1:modalpopupextender&gt;
                                              &lt;cc1:confirmbuttonextender id="lnkDelete_ConfirmButtonExtender2" runat="server" targetcontrolid="ContactlnkDelete" enabled="True" 
                                                      displaymodalpopupid="lnkDelete_ModalPopupExtender2"&gt;
                                             &lt;/cc1:confirmbuttonextender&gt;
                                      &lt;/ItemTemplate&gt;
  
                                 &lt;/asp:TemplateField&gt;
                              &lt;/Columns&gt;
  
  
                         &lt;FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
                         &lt;RowStyle BackColor="#EFF3FB" /&gt;
                         &lt;EditRowStyle BackColor="#2461BF" /&gt;
                         &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /&gt;
                         &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt;
                         &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
                         &lt;AlternatingRowStyle BackColor="White" /&gt;
                 &lt;/asp:GridView&gt; 
  </code></pre>
  
  <p>but it also failed. Please, i need your assistance.</p>