Click here to Skip to main content
15,614,147 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i had a datagrid view with multicoloumn i need to delete grid recods with confirmation, in code behind file the event lnkDelete_Click not firing can any help me to delete the recodrs in grid


             <asp:CommandField Visible="false" />
             <asp:BoundField DataField="EntryTypeName" Visible="true" HeaderText="EntryTypeName"></asp:BoundField>
             <asp:BoundField DataField="ProductName" Visible="true" HeaderText="ProductName"></asp:BoundField>
             <asp:BoundField DataField="VersionNumber" Visible="true" HeaderText="Version "></asp:BoundField>
             <asp:BoundField DataField="BugID" Visible="true" HeaderText="BugID"></asp:BoundField>
             <asp:BoundField DataField="SupportID" Visible="true" HeaderText="SupportID"></asp:BoundField>
             <asp:BoundField DataField="Description" Visible="true" HeaderText="Description"></asp:BoundField>
             <asp:BoundField DataField="Date" Visible="true" HeaderText="Date"></asp:BoundField>
             <asp:BoundField DataField="Effort" Visible="true" HeaderText="Effort"></asp:BoundField>

                  <asp:LinkButton ID="lnkDelete" Runat="server" onclick="lnkDelete_Click" OnClientClick="return confirm('Are you sure you?');"

Updated 10-Jul-13 1:10am

and try!
Share this answer
kesav prakash 10-Jul-13 7:22am    
i already done ya, may i know in which event i need to write the delete code
you can use RowCommand_event of Gridview and in that event delete the record as per your requirement

try this
rowcommand event of gridview[^]
Share this answer
kesav prakash 10-Jul-13 9:35am    
how to to get the datagridview selected cell value(text) without using the row.cell[index]
Naz_Firdouse 10-Jul-13 9:40am    
RowBound event is for a without specifying index,which cell value you want to retrieve?
Share this answer
please assign OnRowCommand

<asp:GridView ID="gvProductReceive" Width="100%" runat="server" AllowPaging="True"
    AutoGenerateColumns="False" CellPadding="4" GridLines="None" AllowSorting="True"
    ForeColor="#333333" PageSize="30" OnPageIndexChanging="gvProductReceive_PageIndexChanging"
    OnRowCommand="gvProductReceive_RowCommand" OnRowDataBound="gvProductReceive_RowDataBound">
    <RowStyle BackColor="#E3EAEB" />

<asp:ImageButton ID="ImgDelete" runat="server" CausesValidation="False" CommandName="CmdDelete"
        CommandArgument='<%# bind("ReceivedId") %>' ImageUrl="~/Images/delete.png" Text=""
        AlternateText="Delete" ToolTip="Delete" />

3. Catch the event on .cs file
protected void gvProductReceive_RowCommand(object sender, GridViewCommandEventArgs e)

    int _ownerDetailId;
    arrayDelete = new ArrayList();
    if (e.CommandName == "CmdDelete")
        _ownerDetailId = Convert.ToInt32(e.CommandArgument.ToString());


hopefully it works
Best regards
Share this answer
kesav prakash 10-Jul-13 9:34am    
how to to get the datagridview selected cell value(text) without using the row.cell[index]
Riasat Azim Dip 10-Jul-13 9:46am    
I think your Question is
DataGrid view delete button firing event problem in :)
you have to do this by row.cell[index] another techniques is not available to me.
Do some RND :)

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900