How to delete one row in GridView with DropDownList in ASP.NET
<p>This is my design page</p>

<pre><code> &lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"     Inherits="newsamplecomb._Default" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head runat="server"&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id="form1" runat="server"&gt;
&lt;div&gt;
 &lt;asp:GridView ID="GridView1" runat="server" ShowFooter="true"   AutoGenerateColumns="False"
        BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
        CellPadding="3" CellSpacing="2"    OnSelectedIndexChanged="GridView1_SelectedIndexChanged1"
        Height="246px" onrowdatabound="GridView1_RowDataBound" Width="1017px"&gt;
        &lt;RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /&gt;
        &lt;Columns&gt;
            &lt;asp:BoundField /&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Rollno&lt;br /&gt;
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:DropDownList ID="DropDownList1" runat="server" Height="23px"    Width="73px" 
                        AutoPostBack="True" 
                        onselectedindexchanged="DropDownList1_SelectedIndexChanged" &gt;
                    &lt;/asp:DropDownList&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Name
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox1" runat="server" Width="155px"    ReadOnly="True"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    English&lt;br /&gt;
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox2" runat="server" Height="17px" Width="103px"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Tamil&lt;br /&gt;
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox3" runat="server" Height="16px" Width="103px"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Maths
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox4" runat="server" Height="16px" Width="103px"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Science
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox5" runat="server" Height="16px" Width="103px"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Total&lt;br /&gt;
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox6" runat="server" Height="16px" Width="103px"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;HeaderTemplate&gt;
                    Grade
                &lt;/HeaderTemplate&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="TextBox7" runat="server" Height="16px" Width="103px"&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:Button ID="ButtonAdd" runat="server" OnClick="ButtonAdd_Click1" Text="+" /&gt;
                    &lt;asp:Button ID="Buttondel" runat="server" Text="Del"&gt;&lt;/asp:Button&gt;
                   &lt;asp:RequiredFieldValidator ID="rfv" runat="server" ErrorMessage="" ForeColor="White" ControlToValidate="TextBox1" Width="10" Display="None"&gt;&lt;/asp:RequiredFieldValidator&gt;
                &lt;/ItemTemplate&gt;
                &lt;FooterStyle HorizontalAlign="Right" /&gt;
            &lt;/asp:TemplateField&gt;
        &lt;/Columns&gt;
        &lt;FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /&gt;
        &lt;PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /&gt;
        &lt;SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /&gt;
        &lt;HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /&gt;
    &lt;/asp:GridView&gt;

&lt;/div&gt;
&lt;%-- //&lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"        ErrorMessage="RequiredFieldValidator" ForeColor="White" ControlToValidate="TextBox1" Width="10"&gt;&lt;/asp:RequiredFieldValidator&gt;--%&gt;
</code></pre>

<p>
    

</p>

<p>This is my cs code</p>

<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var ddl = (DropDownList)e.Row.FindControl("DropDownList1");
            string connection_string = ConfigurationManager.ConnectionStrings["DBC"].ConnectionString;
            SqlConnection con = new SqlConnection(connection_string);
            con.Open();

            SqlCommand cmd = new SqlCommand("Select * from stud_table", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();

            da.Fill(ds);
            //  con.Close();
            ddl.DataSource = ds;
            ddl.DataTextField = "Rollno";
            ddl.DataValueField = "Rollno";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("--Select--", "0"));
        }
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        dpditemdesc( sender,e);
        DropDownList box1 = (DropDownList)GridView1.Rows[x].Cells[1].FindControl("DropDownList1");

        if (box1.Text != "")
        {
            for (int i = 0; i &lt; GridView1.Rows.Count; i++)
            {
                GridView1.Rows[i].Cells[2].Enabled = false;
                GridView1.Rows[i].Cells[3].Enabled = false;
                GridView1.Rows[i].Cells[4].Enabled = false;
                GridView1.Rows[i].Cells[5].Enabled = false;
                GridView1.Rows[i].Cells[6].Enabled = false;
                GridView1.Rows[i].Cells[7].Enabled = false;
                GridView1.Rows[i].Cells[8].Enabled = false;
            }
        }
        else
        {
            for (int i = 0; i &lt; GridView1.Rows.Count; i++)
            {
                GridView1.Rows[i].Cells[2].Enabled = true;
                GridView1.Rows[i].Cells[3].Enabled = true;
                GridView1.Rows[i].Cells[4].Enabled = true;
                GridView1.Rows[i].Cells[5].Enabled = true;
                GridView1.Rows[i].Cells[6].Enabled = true;
                GridView1.Rows[i].Cells[7].Enabled = true;
                GridView1.Rows[i].Cells[8].Enabled = true;
            }
        }
    }
    public void dpditemdesc(object sender, EventArgs e)
    {
        DropDownList ddl = (DropDownList)sender;
        GridViewRow row = (GridViewRow)ddl.NamingContainer;
        x = row.RowIndex;
        TextBox box = (TextBox)GridView1.Rows[x].Cells[2].FindControl("TextBox1");
        if (box.Text == "")
        {
            try
            {
                x = Convert.ToInt32(Session["ct"].ToString());
                x++;
                Session["ct"] = x.ToString();
            }
            catch
            {
                x = 0;
                Session["ct"] = x.ToString();
            }
        }
        if (ddl.SelectedIndex != 0)
        {
        string connection_string =     ConfigurationManager.ConnectionStrings["DBC"].ConnectionString;
        SqlConnection con = new SqlConnection(connection_string);

        DropDownList box1 =                                 (DropDownList)GridView1.Rows[x].Cells[1].FindControl("DropDownList1");
        TextBox box2 = (TextBox)GridView1.Rows[x].Cells[2].FindControl("TextBox1");
        TextBox box3 = (TextBox)GridView1.Rows[x].Cells[3].FindControl("TextBox2");
        TextBox box4 = (TextBox)GridView1.Rows[x].Cells[4].FindControl("TextBox3");
        TextBox box5 = (TextBox)GridView1.Rows[x].Cells[5].FindControl("TextBox4");
        TextBox box6 = (TextBox)GridView1.Rows[x].Cells[6].FindControl("TextBox5");
        TextBox box7 = (TextBox)GridView1.Rows[x].Cells[7].FindControl("TextBox6");
        TextBox box8 = (TextBox)GridView1.Rows[x].Cells[8].FindControl("TextBox7");


        SqlCommand cmd = new SqlCommand("select * from stud_table where Rollno='" + box1.Text + "'", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            box2.Text = ds.Tables[0].Rows[0][1].ToString();
            box3.Text = ds.Tables[0].Rows[0][2].ToString();
            box4.Text = ds.Tables[0].Rows[0][3].ToString();
            box5.Text = ds.Tables[0].Rows[0][4].ToString();
            box6.Text = ds.Tables[0].Rows[0][5].ToString();
            box7.Text = ds.Tables[0].Rows[0][6].ToString();
            box8.Text = ds.Tables[0].Rows[0][7].ToString();
        }
        else
        {
            // box.Text = "";
            Response.Write("&lt;Script&gt;alert('Please Select Item Description')&lt;/script&gt;");
        }

    }
}
}
</code></pre>

<p>I want to select one row and, if I click delete button, the selected row should be deleted.</p>
