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
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.

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.