<
asp:ButtonFieldCommandName="select"Text="Delete item"/> Now this works, i click the button and it runs the removeCartItem Sub and it deletes the item. I figured that this is a bit...unefficient since the OnSelected is supposed to be used when clicking the select button.I tried switching it to "onRowDeleted="RemoveCartItem", so i could free up select for other things (as well as the fact i want to add others for editing etc) but as soon as i switch to onRowDeleted i get the following error:
Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message:BC30408: Method 'Public Sub RemoveCartItem(s As Object, e As System.EventArgs)' does not have the same signature as delegate 'Delegate Sub GridViewDeletedEventHandler(sender As Object, e As System.Web.UI.WebControls.GridViewDeletedEventArgs)'.
-----------
So i'm assuming my sub doesn't follow the standard for the delete command or something?. my sub is:
Sub RemoveCartItem(ByVal sAsObject,ByVal eAs EventArgs)Dim IDAsString =CInt(CartGrid.SelectedDataKey.Value)
Profile.ShoppingCart.RemoveItem(ID)
BindShoppingCart()
Response.Redirect("cart.aspx")EndSub
--
And this is in a sperate class file:
-
PublicSub RemoveItem(ByVal IDAsInteger)Dim itemAs CartItem =CType(_CartItems(ID), CartItem)If itemIsNothingThenReturnEndIfIf item.Quantity >= 0Then_CartItems.Remove(ID)
Else_CartItems(ID) = item
EndIfEndSub-------Hi all!I've got a quite big problem!We get connected to a SYBASE DataBase, and we usually use stored...
By lonifasiko
I have a MS Access database where the Datatables are stored in a file named *_be.mdb (astrisk in pla...
By war40k
This is more SQL Server than ADO, but this seemed the closest discussion group to what I need.The sp...
By petedavis
My name is Asad Naeem. I am new to Oracle. Here in my company i have to work in Oracle 8.5. But i ha...
By anuab_lg_yahoo
Hello thereI am trying to find the DataGrid, chart and stuff that will work with Mac IE and Safari, ...
By drstrangelove
Hi, I have an 'add new' button on my page outside of the datagrid. What happens now is it brings up ...
By raif
Hi i need help to store information in a datagrid to the database.(The information come form webserv...
By rainoh
Hi guys, was hoping that someone may be able to help. When you click the select button, in a gridvie...
By phil_c_, 10 Comments
Does anyone know anything about using the onItemBound subroutines for a repeater? I need to check th...
By kcastle, 4 Comments
In my ASP.NET 2.0 Package when entering customer data, when I use XYZ & Company as Customer Name, it...
By kbnsarma, 5 Comments
hello experts,need your expert look on this codeI'm trying to access a store Procedure (sp_no935) in...
By meghoo, 5 Comments
Hi,I am trying to make a coloured label visible depending on a value in another control using the st...
By colinj, 2 Comments
SQLServer 2000 .Net 2005 COM+ component SQL Command Object (using ExecuteNonQuery service w/Com...
By di_mgmt, 4 Comments
CREATE PROC xxx@user VARCHAR(15),@rank varCHAR(10) ASDECLARE @sql VARCHAR(100)SET @sql = 'insert...
By tweety_net, 9 Comments
I have got a datalist and what i am trying to do is to get it to show the cost of an item i.e. if th...
By bulgy, 8 Comments
Hi
Yes the message is correct... every event is implemented as delegate.. and your custom method signature is not matching the expected delegate signature.. pls see if this helps
change your method declaration to
Sub RemoveCartItem(ByVal sAsObject,ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs)
When calling this method call it as
RemoveCartItem(GridView1,EventArgs.Empty)
Hope this helps.
VJ
vijayvrr_2001 | Sun, 06 Jan 2008 10:04:00 GMT |
The error tells you what the problem is. This:
s As Object, e As System.EventArgs
isn't the same as what the delete method should have i.e.
sender As Object, e As System.Web.UI.WebControls.GridViewDeletedEventArgs
ca8msm | Sun, 06 Jan 2008 10:05:00 GMT |
i changed the following:
Sub RemoveCartItem(ByVal sAsObject,ByVal eAs System.Web.UI.WebControls.GridViewDeletedEventArgs)Dim IDAsString =CInt(CartGrid.SelectedDataKey.Value)Profile.ShoppingCart.RemoveItem(ID)
BindShoppingCart()
Response.Redirect("cart.aspx")
EndSuband
OnRowDeleted="RemoveCartItem(GridView1,EventArgs.Empty)"
. but im still getting the same error. when im doing removeItem in the method, should i remove name, quantity etc, as well as the ID?, or is the ID enough
deathcab1 | Sun, 06 Jan 2008 10:06:00 GMT |
oh, i changed the ID to the ID of my grid view and that error has now gone, but i have:
Error 28 'AddressOf' operand must be the name of a method (without parentheses). C:\Safle2\Cart.aspx 58
deathcab1 | Sun, 06 Jan 2008 10:07:00 GMT |
Hi
I am not too sure how to do it declaratively (as a part of the definition), but can you try this programatically, which is
Sub Page_Load
AddHandler <your gridview name>.RowDeleted, AddressOf RemoveItem
' Note: (No paranthesis after RemoveItem)
End Sub
VJ
vijayvrr_2001 | Sun, 06 Jan 2008 10:08:00 GMT |
hmm, that doesnt seem to work either. RemoveItem needed to be declared, but i changed that to the name of my method (removeCartItem) and no problem, just the addressOf error appears again.
Sub Page_Load()AddHandler CartGrid.RowDeleted,AddressOf RemoveCartItemError 28 'AddressOf' operand must be the name of a method (without parentheses). C:\Safle\Cart.aspx 56
but that is the name of my method - Remove cart item
deathcab1 | Sun, 06 Jan 2008 10:09:00 GMT |
Hideathcab1 ,
There are many other ways to define a button to delete. My suggestion is to put a button in ItemTemplate then set CommandName to any string except delete,insert and update. You can write some codes behind to delete records.
Have a look at my sample,
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "del")
{
string id = e.CommandArgument.ToString();
//delete here
}
}
samuzhang_msft | Sun, 06 Jan 2008 10:10:00 GMT |