title: change table gridview select wrong row
body: <p>i have page load to load gridview from database
  and i have textbox and search button can change the gridview. but that problem is gridview_selectindexchanging select wrong row. </p>
  
  <pre><code>        protected void GridView1_SelectedIndexChanging1(object sender, GridViewSelectEventArgs e)
      {
  
          lbl_1.Visible = true;
          lbl_2.Visible = true;
          lbl_3.Visible = true;
          lbl_4.Visible = true;
          lbl_5.Visible = true;
          lbl_6.Visible = true;
          lbl_7.Visible = true;
          btn_submit.Visible = true;
          lbl_nama.Text = GridView1.Rows[e.NewSelectedIndex].Cells[1].Text;
          lbl_alamat.Text = GridView1.Rows[e.NewSelectedIndex].Cells[2].Text;
          lbl_hp.Text = GridView1.Rows[e.NewSelectedIndex].Cells[3].Text;
          lbl_kode.Text = GridView1.Rows[e.NewSelectedIndex].Cells[4].Text;
          lbl_peminjaman.Text = GridView1.Rows[e.NewSelectedIndex].Cells[5].Text;
          lbl_pengembalian.Text = GridView1.Rows[e.NewSelectedIndex].Cells[6].Text;
  
          DateTime kembali = DateTime.ParseExact(lbl_pengembalian.Text,"dd-MM-yyyy",CultureInfo.InvariantCulture);
          if (DateTime.Now &gt; kembali)
          {
              lbl_denda.Text = "Rp.20000,-";
          }
          else
          {
              lbl_denda.Text = "Rp.0,-";
          }
      }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>            &lt;asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" style="text-align: left" AutoGenerateSelectButton="true" OnSelectedIndexChanging="GridView1_SelectedIndexChanging1"&gt;
              &lt;AlternatingRowStyle BackColor="White" /&gt;
              &lt;FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
              &lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
              &lt;PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /&gt;
              &lt;RowStyle BackColor="#FFFBD6" ForeColor="#333333" /&gt;
              &lt;SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /&gt;
              &lt;SortedAscendingCellStyle BackColor="#FDF5AC" /&gt;
              &lt;SortedAscendingHeaderStyle BackColor="#4D0000" /&gt;
              &lt;SortedDescendingCellStyle BackColor="#FCF6C0" /&gt;
              &lt;SortedDescendingHeaderStyle BackColor="#820000" /&gt;
          &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>how to fix this problem?</p>