Hi,
I am having an issue deleting records from my grid, which I am binding to an ObjectDataSource.
Code below:
function doDeleteRows() { var valid = true; var gridRows = grid.get_rows(); var selectedRows = grid.get_behaviors().get_selection().get_selectedRows(); // do we have any rows selected if (selectedRows.length == 0) { valid = false; displayPageTextMessage("You must select at least one row to delete.", true); } else { var confirmation; if (selectedRows._keys.length == 1) { confirmation = "Are you sure you want to delete the selected line (1 record)?"; } else { confirmation = "Are you sure you want to delete the selected line (" + selectedRows._keys.length + " records)?"; } valid = confirm(confirmation); } if (valid) { for (var i = selectedRows.get_length() - 1; i >= 0; i--) { var row = selectedRows.getItem(i); gridRows.remove(row); } displayPageTextMessage("Deleted succesfully.", true); }
return false; }
<ig:WebDataGrid ID="myGrid" DataKeyFields="account_line_id, CSBALine" runat="server" Width="100%" Height="100%" DataSourceID="odsAccountLineList" AutoGenerateColumns="false" StyleSetName="ElectricBlue" Font-Names="Arial Monospaced"> <ClientEvents Initialize="myGrid_Initialize" /> <Behaviors> <ig:Activation Enabled="true"></ig:Activation> <ig:ColumnMoving DragStyle="Follow" Enabled="true"> <ColumnSettings> <ig:ColumnMoveSetting ColumnKey="Attachment" EnableMove="false" /> <ig:ColumnMoveSetting ColumnKey="CSBALine" EnableMove="false" /> </ColumnSettings> </ig:ColumnMoving> <ig:ColumnResizing Enabled="true"></ig:ColumnResizing> <ig:EditingCore> <Behaviors> <ig:CellEditing Enabled="true" EditModeActions-MouseClick="Double" EditModeActions-EnableOnKeyPress="true"> </ig:CellEditing> </Behaviors> </ig:EditingCore> <ig:Paging Enabled="false" ></ig:Paging> <ig:RowSelectors Enabled="true"></ig:RowSelectors> <ig:Sorting Enabled="false"></ig:Sorting> <ig:Selection CellClickAction="Cell" CellSelectType="None" ColumnSelectType="None" RowSelectType="Multiple"></ig:Selection> </Behaviors> </ig:WebDataGrid> <asp:ObjectDataSource ID="odsAccountLineList" runat="server" TypeName="BusinessManager" EnablePaging="false" SelectMethod="GetAccountLineDataTableForWebGrid" OnSelecting="odsAccountLineList_Selecting" UpdateMethod="UpdateAccountLine" OnUpdating="odsAccountLineList_Updating" DeleteMethod="DeleteAccountLine"> <SelectParameters> <asp:Parameter Name="subcommitteeId" /> <asp:Parameter Name="fiscalYear" /> <asp:Parameter Name="filters" /> <asp:Parameter Name="user" /> </SelectParameters> <DeleteParameters> <asp:ControlParameter ControlID="hfFiscalYear" Type="String" Name="fiscalYear" PropertyName="Value" /> <asp:Parameter Name="account_line_id" Type="Int32" /> </DeleteParameters> </asp:ObjectDataSource>
I have a menu item on the page that calls doDeleteRows(). I get the error message selecting one or multiple rows. The error says:
InvalidOperationException
ObjectDataSource 'odsAccountLineList' could not find a non-generic method 'DeleteAccountLine' that has parameters: fiscalYear, account_line_id, CSBALine.
However, I do have a method as such. In fact, I even created a method stub with the third parameter just to trick it as below:
<DataObjectMethod(DataObjectMethodType.Delete)> Public Shared Function DeleteAccountLine(ByVal fiscalYear As String, ByVal account_line_id As Integer, ByVal CSBALine As Integer) As Boolean ' delete the record CSBADAL.DeleteAccountLine(fiscalYear, account_line_id) Return True End Function
Your help is very appreciated.
P.S. what's the proper way to post code in tags on here?
Hello Khaled ,
Thank you for posting in our forum.
Could you let me know which version of our controls you’re using?
I tried reproducing your issue on my side based on the code snippet you provided but so far I’ve noticed no issue.
I’m attaching the sample for your reference. You can select some rows and click on the button. The DeleteMethod for the ObjectDataSource is fired as expected.
Let me know if I’m missing something from your scenario.
I’m looking forward to your reply.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Hi Maya,
Thanks for your reply. I checked out your sample and it looked fine. I am still have the same issue and have not been able to get away from it.
I am using Infragistics4.Web.v12.2
Hello Khaled,
I'm just following up to see whether you've managed to resolve your issue. Let me know if you need any further assistance with this.