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
arameter Name="transactionid" Type="Int32" />
<asp
arameter Name="transactionamount" Type="Int32" />
<asp
arameter Name="AccountDebitID" Type="Int32" />
<asp
arameter 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.
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
<asp
<asp
<asp
</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.