Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET C#3.5
Dear Experts,
plz can u suggest me C# code...for delete using checkbox in using c#..
And also i want to display here name and image.
I tried this code but not cmg..
this is my design page...
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="id" DataSourceID="SqlDataSource1">
        <asp:CheckBox ID="chkdelete" runat="server" />
        <asp:BoundField DataField="id" HeaderText="id" />
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:BoundField DataField="Image" HeaderText="Image" />
        <asp:SqlDataSource ID="SqlDataSource1" Runat="server"
    SelectCommand="SELECT id, Name, image FROM showdetails"
    DeleteCommand="DELETE FROM showdetails WHERE id = @id"
    ConnectionString="<%$ ConnectionStrings:sss %>" >

    <asp:Button ID="btndelete" runat="server" Text="Delete"
        onclick="btndelete_Click" />
And My asp.cs page
protected void btndelete_Click(object sender, EventArgs e)
        foreach (GridViewRow row in GridView1.Rows)
            CheckBox checkbox = (CheckBox)row.FindControl("chkdelete");

            if (checkbox.Checked)
                int id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                SqlDataSource1.DeleteParameters["id"].DefaultValue = id.ToString();
Posted 4-Sep-12 22:09pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please refer answer for similar question,
Delete rows from datgridview and database access[^]
You will get some help from it, for sure.
For image in grid have a look:
Display Images In GridView From DataBase Asp.Net[^]
MSDN: Displaying Images in a GridView Column[^]
Displaying Images from a Database in a GridView[^]
Member 9376025 at 5-Sep-12 4:37am
i did same code .but i want to display here image in gridview
Prasad_Kulkarni at 5-Sep-12 4:39am
You want to delete check box selected row or display image in grid?? or both?
Member 9376025 at 5-Sep-12 4:47am
Prasad_Kulkarni at 5-Sep-12 4:48am
Refer updated answer..
Member 9376025 at 5-Sep-12 6:43am
thanks prasad

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 5 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid