How to delete all selected checkbox value and there particular row?
<p>i have a table which has only title field. I  am not using ID field in this table as its not required. 
Now on my front page i have a grid view which display title and there is a column item template check box. 
I want to delete all selected checkbox value and there particular row.
How to do it.?
Anybody can suggest me that...
Thanks In advance... 
i am doing..</p>

<pre><code>    private void GetData()
    {
        grdlistWord.
        ArrayList arr;
        if (ViewState["TotalRecords"] != null)
        {
            arr = (ArrayList)ViewState["TotalRecords"];
        }
        else
        {
            arr = new ArrayList();
        }
        for (int i = 0; i &lt; grdlistWord.Rows.Count; i++)
        {

            CheckBox chk = (CheckBox)grdlistWord.Rows[i].Cells[0].FindControl("chkWord");
            if (chk.Checked)
            {
                if (!arr.Contains(grdlistWord.DataKeys[i].Value))
                {
                    arr.Add(grdlistWord.DataKeys[i].Value);
                }
            }
            else
            {
                if (arr.Contains(grdlistWord.DataKeys[i].Value))
                {
                    arr.Remove(grdlistWord.DataKeys[i].Value);
                }
            }
            //}
        }
        ViewState["TotalRecords"] = arr;
    }

    protected void lnkbtnDelete_Click(object sender, EventArgs e)
    {
        {
            try
            {
                int count = 0;
                //SetData();
                //gvAll.AllowPaging = false;
                //gvAll.DataBind();
                ArrayList arr = (ArrayList)ViewState["TotalRecords"];
                count = arr.Count;
                for (int i = 0; i &lt; grdlistWord.Rows.Count; i++)
                {
                    //string a = grdlistWord.Rows.Count.ToString();
                    //Response.Write(a.ToString());
                    if (arr.Contains(grdlistWord.DataKeys[i].Value))
                    {

                        DeleteRecord(grdlistWord.DataKeys[i].Value.ToString());
                        arr.Remove(grdlistWord.DataKeys[i].Value);
                    }
                }
                ViewState["TotalRecords"] = arr;
                //hfCount.Value = "0";
                //gvAll.AllowPaging = true;
                GridBind();
                //ShowMessage(count);
            }
            catch (SqlException ex)
            {
                ex.ToString();
            }
        }
    }


    private void DeleteRecord(string word)
    {

        string query = "delete from searchword where word=@word";

        SqlCommand cmd = new SqlCommand(query, con);
        cmd.Parameters.AddWithValue("@word", word);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
</code></pre>

<p>HTML Code:</p>


            
                
            
            
                Word:
                
            
            
                
                
            
        

<pre><code>    &lt;fieldset&gt;
        &lt;legend&gt;List&lt;/legend&gt;
        &lt;asp:GridView ID="grdlistWord" runat="server" DataKeyNames="word" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" OnRowDataBound="grdlistWord_RowDataBound" OnRowDeleting="grdlistWord_RowDeleting" Width="456px" &gt;
            &lt;Columns&gt;
                &lt;asp:TemplateField&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:CheckBox ID="chkWord" runat="server" onclick="check_click(this);" OnCheckedChanged="chkWord_CheckedChanged" /&gt;

                    &lt;/ItemTemplate&gt;
                    &lt;HeaderTemplate&gt;
                        &lt;asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" /&gt;
                        &lt;asp:LinkButton ID="lnkbtnDelete" runat="server" Text="Delete" OnClick="lnkbtnDelete_Click" ForeColor="white"&gt;&lt;/asp:LinkButton&gt;
                    &lt;/HeaderTemplate&gt;
                &lt;/asp:TemplateField&gt;
                &lt;asp:BoundField DataField="Word" HeaderText="Word" /&gt;
                &lt;asp:HyperLinkField HeaderText="Edit" Text="edit" DataNavigateUrlFields="Word" DataNavigateUrlFormatString="SearchWord.aspx?words={0}&amp;amp;mode=Edit" /&gt;
                &lt;asp:CommandField ShowDeleteButton="True" HeaderText="Delete" /&gt;
            &lt;/Columns&gt;
            &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
            &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
            &lt;EditRowStyle BackColor="#999999" /&gt;
            &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt;
            &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
            &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
            &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt;
            &lt;EmptyDataTemplate&gt;Records not exist!&lt;/EmptyDataTemplate&gt;
        &lt;/asp:GridView&gt;
        &lt;asp:HiddenField ID="hfCount" runat="server" Value = "0" /&gt;

    &lt;/fieldset&gt;
</code></pre>
