This is a migrated thread and some comments may be shown as answers.

problem deleting multiple rows

2 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 16 Sep 2008, 05:48 AM
Hi all,

I'm having some problems deleting multiple rows in my grid. I have the MasterTableView and inside it I have my CommandItemTemplate which have the respective controls to manipulate the grid (add registers, delete registers and refresh).

The problem is that i have a button and a linkbutton for every function (image and text) and all works perfect, but the button to delete seleted rows doesn't works. It just works until de OnClientClick event, but does matter what the user clicks (ok or cancel)  it never axecute the delete event  ...... for the link button it works fine.

Here is my code
<CommandItemTemplate>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
    <tr>
        <td align="center">
            <asp:Button ID="btnNew" runat="server" CommandName="InitInsert" CssClass="rgAdd" CausesValidation="false" />
        </td>
        <td align="center">
            <asp:Button ID="btnDeleteSelected" runat="server" CommandName="DeleteSelected" CssClass="rgDel" CausesValidation="false" OnClientClick="javascript:return confirm('Borrar todos los usuarios seleccionados?')" />
        </td>
        <td align="center">
            <asp:Button ID="btnRefresh" runat="server" CommandName="RebindGrid" CssClass="rgRefresh" CausesValidation="false" />
        </td>
        <td width="100%">&nbsp;</td>
    </tr>
    <tr>
        <td align="center">
            <asp:LinkButton ID="lbtnNew" runat="server" CommandName="InitInsert" CausesValidation="false" Text="Nuevo" />
        </td>
        <td align="center">
            <asp:LinkButton ID="lbtnDeleteSelected" runat="server" CommandName="DeleteSelected" OnClientClick="javascript:return confirm('Borrar todos los usuarios seleccionados?')" CausesValidation="false" Text="Borrar Seleccionados" />
        </td>
        <td align="center">
            <asp:LinkButton ID="lbtnRefresh" runat="server" CommandName="RebindGrid" CausesValidation="false" Text="Refrescar" />
        </td>
        <td width="100%">&nbsp;</td>
    </tr>
</table>
</CommandItemTemplate>

I hope you can help me with this


Regards,

Daniel Peralta

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 16 Sep 2008, 07:20 AM
Hi Daniel,

I tried this on my end and it is working correctly. Can you try setting the Confirm for the button on the server side and see if it is working?

ASPX:
  <CommandItemTemplate> 
       <asp:Button ID="Button3" runat="server"   CommandName="DeleteSelected"  Text="Delete" /> 
    </CommandItemTemplate> 

CS:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridCommandItem) 
        { 
 
            GridCommandItem cmditm = (GridCommandItem)e.Item; 
            Button btn = (Button)cmditm.FindControl("Button3"); 
            if (btn != null) 
                btn.Attributes.Add("onclick", "javascript:return confirm('Do you want to delete?')"); 
        } 
 } 

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "DeleteSelected") 
        { 
           foreach(GridDataItem SeletedItem in RadGrid1.SelectedItems ) 
           { 
            //perform the delete operation 
           } 
        } 
 
    } 


Thanks
Shinu
0
Daniel
Top achievements
Rank 1
answered on 16 Sep 2008, 03:15 PM
Hi and thx for the reply,

But it also didn't works .... it happend just the same thing .. it ask me if i want to delete, but after I click 'OK' it doesnt execute the delete command (for the link button it works),

So I tried a similar solution but adding the attribute to the button in the load event:
       
btnDeleteSelected.Attributes.Add("onclick", "javascript:if(confirm('Borrar todos los registros seleccionados?')== false) return false;");

Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Share this question
or