specified cast is not valid

P

planet

Hi,

I wish I can solve this problem not having recode the sub. Here is
goes: I got this error' specified cast is not valid' at the second
line. from the code

Sub ChkDelete_OnCheckedChanged(ByVal sender As Object, ByVal e As
EventArgs)
DataGrid1_DeleteCommand(sender, e)

What I was trying to do is in the checkbox oncheckChanges event calls
the datagrid's deleteCommand. The linkbutton is set visible =false.
So the user click the checkbox, the linkbutton is triggered. But I
think the problem is the 'sender' I put at the second line. Because
the first argument in the DataGrid1_deleteCommand is (ByVal source As
Object,)

How to cast it? I think is the question. If anyone knows, please help!


Stack Trace:


[InvalidCastException: Specified cast is not valid.]
Query.Query.ChkDelete_OnCheckedChanged(Object sender, EventArgs e)
in c:\inetpub\wwwroot\Query\stock1.aspx.vb:475
System.Web.UI.WebControls.CheckBox.OnCheckedChanged(EventArgs e)

System.Web.UI.WebControls.CheckBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
System.Web.UI.Page.RaiseChangedEvents()
System.Web.UI.Page.ProcessRequestMain()
 
B

Baski

DataGrid's DeleteCommand takes CommandEventArgument as param but you are
passing sender which is nothing but checkbox itself.

What you can to create an instance of CommandEventArgument and inside set
all the required properties and also set source object to checkbox (if
needed).
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top