title: Deleting in gridview not working
body: <p>i designed a page for admin to search users from database table using a Get button and delete users in gridview</p>
  
  <p>This my source coding..</p>
  
  <pre><code>                &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" DataKeyNames="username"  EnableModelValidation="True" OnRowDeleting="GridView1_RowDeleting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged1"&gt;
                      &lt;Columns&gt;
                          &lt;asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" /&gt;
                          &lt;asp:BoundField DataField="name" HeaderText="name" SortExpression="name" /&gt;
                          &lt;asp:BoundField DataField="adm" HeaderText="adm" SortExpression="adm" /&gt;
                          &lt;asp:BoundField DataField="mobno" HeaderText="mobno" SortExpression="mobno" /&gt;
                          &lt;asp:BoundField DataField="branch" HeaderText="branch" SortExpression="branch" /&gt;
                          &lt;asp:BoundField DataField="year" HeaderText="year" SortExpression="year" /&gt;
                          &lt;asp:BoundField DataField="username" HeaderText="username" ReadOnly="True" SortExpression="username" /&gt;
                          &lt;asp:BoundField DataField="password" HeaderText="password" SortExpression="password" /&gt;
                          &lt;asp:BoundField DataField="usertype" HeaderText="usertype" SortExpression="usertype" /&gt;
                      &lt;/Columns&gt;
                  &lt;/asp:GridView&gt;
                  &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:CanteenConnectionString %&gt;" SelectCommand="SELECT * FROM [Hosteller]" DeleteCommand="DELETE FROM Hosteller WHERE (username = @username)"&gt;
                      &lt;DeleteParameters&gt;
                          &lt;asp:Parameter Name="username" /&gt;
                      &lt;/DeleteParameters&gt;
                  &lt;/asp:SqlDataSource&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code> protected void btnget_Click(object sender, EventArgs e)
          {
              DataTable dt = new DataTable();
              string ConString = "Data Source=sheikha-pc\\sqlexpress;Initial Catalog=Canteen;Integrated Security=True";
              SqlConnection con = new SqlConnection(ConString);
              string qry = "select id,name,adm,mobno,branch,year,username,password,usertype from Hosteller where adm='" + txtsearch1.Text + "'";
              SqlDataAdapter adpt = new SqlDataAdapter(qry, con);
              adpt.Fill(dt);
              if (dt.Rows.Count == 0)
              {
                  GridView1.EmptyDataText = "No data found";
                  GridView1.DataBind();
              }
              else
              {
                  GridView1.DataSource = dt;
                  GridView1.DataBind();
              }
  
          }
  </code></pre>
  
  <p>this is the coding that i wrote for GET button</p>
  
  <p>the problem is when i click on delete it doesnt work! please help.........</p>