C# Identifying the Row in a gridview inorder to Delete
<p>I am working on a project in which I am to display, insert, delete the data in my access database. I made buttons that will display a specific table from the database. I then made an asp column to display the delete button next to each row. The issue that I am trying to figure out is: How can I have it so that when the delete button is clicked the specific row is identified so then I may delete it? Any hints or tips are welcomed. Thank you. </p>

<pre><code>&lt;body&gt;
 &lt;h1 class="center" style="text-align: center" &gt;Display, Delete, and Add&lt;/h1&gt;
&lt;h3 id="Title1"&gt;&lt;/h3&gt;
&lt;style&gt;
.center{
    margin: 0 auto;
}

&lt;/style&gt;

&lt;form id="form1"  runat="server"&gt;
    &lt;asp:GridView ID="GridView1" class="center" runat="server" Width="300px" &gt;
        &lt;Columns&gt;
            &lt;asp:TemplateField&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:Button ID="btn1" Text="Delete" runat="server" OnClick="btn1_Click"/&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
        &lt;/Columns&gt;
    &lt;/asp:GridView&gt;
    &lt;p&gt;
        &amp;nbsp;&lt;/p&gt;
    &lt;p &gt;
        &lt;asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Courses"  /&gt;
        &lt;asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Student Information" /&gt;
        &lt;asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Students" /&gt;
    &lt;/p&gt;
    &lt;p&gt;
        &amp;nbsp;&lt;/p&gt;
    &lt;p&gt;
        &amp;nbsp;&lt;/p&gt;
    &lt;p&gt;
        &amp;nbsp;&lt;/p&gt;
&lt;/form&gt;
</code></pre>

<p></p>

<pre><code>public partial class _Default : System.Web.UI.Page
{
    OleDbConnection con = new OleDbConnection  (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\achowdhary\Documents\Database1.accdb");
protected void Page_Load(object sender, EventArgs e)
{

}


protected void Button1_Click1(object sender, EventArgs e)
{


    OleDbDataAdapter ada = new OleDbDataAdapter(" SELECT * FROM COURSES", con);
    DataSet set = new DataSet();
    ada.Fill(set, "COURSES");

    DataTable tab = new DataTable();
    tab = set.Tables["COURSES"];

    GridView1.DataSource = tab;
    GridView1.DataBind();



}

protected void Button2_Click(object sender, EventArgs e)
{
    OleDbDataAdapter ada = new OleDbDataAdapter(" SELECT * FROM STUDENT_INFO", con);
    DataSet set = new DataSet();
    ada.Fill(set, "STUDENT_INFO");

    DataTable tab = new DataTable();
    tab = set.Tables["STUDENT_INFO"];

    GridView1.DataSource = tab;
    GridView1.DataBind();
}

protected void Button3_Click(object sender, EventArgs e)
{
    OleDbDataAdapter ada = new OleDbDataAdapter(" SELECT * FROM STUDENTS", con);
    DataSet set = new DataSet();
    ada.Fill(set, "STUDENTS");

    DataTable tab = new DataTable();
    tab = set.Tables["STUDENTS"];

    GridView1.DataSource = tab;
    GridView1.DataBind();
}

protected void btn1_Click(object sender, EventArgs e)
{
    //ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "hello" + "');", true);

}
</code></pre>

<p>}</p>