<asp:GridView AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<input id="CustomerID" type="checkbox" runat="server" value='<%# Eval("CustomerID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"/>
<asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName"/>
</Columns>
</asp:GridView>


protected void DeleteSelectedRows_Click(object sender, EventArgs e)
{
//Iterate through all the GridViews Rows
foreach (GridViewRow row in GridView1.Rows)
{
//Get the first column from the row where the HtmlInputCheckBox is located
TableCell cell = row.Cells[0];
//Get the HtmlInputChecklBox control from the cells control collection
HtmlInputCheckBox checkBox = cell.Controls[1] as HtmlInputCheckBox;
//If the checkbox exists and are checked, execute the Delete command where the
//value form the HtmlInputCheckBox Value property is set as the value of the 
//delete commands parameter.
if (checkBox != null && checkBox.Checked)
{
SqlDataSource1.DeleteParameters["CustomerID"].DefaultValue = checkBox.Value;
SqlDataSource1.Delete();
}
}
}



<asp:SqlDataSource ID="SqlDataSource1" Runat="server"
SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle] FROM [Customers]"
DeleteCommand="DELETE [Customers] WHERE [CustomerID] = @CustomerID"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>">
<DeleteParameters>
<asp:Parameter Type="String" Name="CustomerID"></asp:Parameter>
</DeleteParameters>
</asp:SqlDataSource>
<asp:Button ID=" DeleteSelectedRows " OnClick=" DeleteSelectedRows _Click" runat="server" Text="Button" />
