By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,292 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,292 IT Pros & Developers. It's quick & easy.

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

P: n/a
I have a gridview which uses an objectdatasource for its select and

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

Dim deleteaccounts As New trans
deleteaccounts.AddToAccountBalance(AccountCreditID ,

Dim transdel As New

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">
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="displaylast10trans" TypeName="trans">
<asp:Parameter Name="transactionid" Type="Int32" />
<asp:Parameter Name="transactionamount" Type="Int32" />
<asp:Parameter Name="AccountDebitID" Type="Int32" />
<asp:Parameter Name="AccountCreditID" Type="Int32" />
<br />
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1" DataKeyNames="transactionid">
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:Label ID="Label1" runat="server"

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

Thank you,


Sep 25 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.