Gridview delete logic problem - Can anyone figure out what's wrong?

S

Steve

I have a gridview which uses an objectdatasource for its select and
delete.

The delete command uses the function below. The delete itself works but
the extra logic which requires parameters AccountDebitID and
AccountCreditID does not work.

'Delete a transaction

Sub deletetrans(ByVal transactionid As Integer, ByVal transactionamount
As Integer, ByVal AccountDebitID As Integer, ByVal AccountCreditID As
Integer)

Dim deleteaccounts As New trans
deleteaccounts.AddToAccountBalance(AccountCreditID,
transactionamount)
deleteaccounts.SubToAccountBalance(AccountDebitID,
transactionamount)

Dim transdel As New
transacsTableAdapters.TransactionsTableAdapter
transdel.DeleteTransaction(transactionid)

End Sub


The function works perfectly fine when I use it indpendently of the
gridview. But within the gridview it gives the error:

"There is no row at position 0." which is due to the value of the
AccountCreditID and AccountDebitID not being correctly passed on to the
function. So the problem lies somewhere in the gridview, but I can't
figure out what I am doing wrong.

The source for my objectdatasource and gridview is as follows:

<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="deletetrans"
SelectMethod="displaylast10trans" TypeName="trans">
<DeleteParameters>
<asp:parameter Name="transactionid" Type="Int32" />
<asp:parameter Name="transactionamount" Type="Int32" />
<asp:parameter Name="AccountDebitID" Type="Int32" />
<asp:parameter Name="AccountCreditID" Type="Int32" />
</DeleteParameters>
</asp:ObjectDataSource>
<br />
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1" DataKeyNames="transactionid">
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label></div>
</form>

Can anyone figure out what I am doing wrong? Why aren't the values of
AccountDebitID and AccountCreditID being passed on to the delete
function?

Thank you,

Steve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top