473,499 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

specified cast is not valid

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.OnCheckedChange d(EventArgs e)

System.Web.UI.WebControls.CheckBox.System.Web.UI.I PostBackDataHandler.RaisePostDataChangedEvent()
System.Web.UI.Page.RaiseChangedEvents()
System.Web.UI.Page.ProcessRequestMain()

Sep 21 '06 #1
1 1707
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).

"planet" <st********@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
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.OnCheckedChange d(EventArgs e)

System.Web.UI.WebControls.CheckBox.System.Web.UI.I PostBackDataHandler.RaisePostDataChangedEvent()
System.Web.UI.Page.RaiseChangedEvents()
System.Web.UI.Page.ProcessRequestMain()

Sep 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3608
by: Tao | last post by:
I just upgraded .NET framework to 1.1 and VS.Net to 2003 version and tried to test it out. I created an ASP.NET project using the wizard and tried to run it by hitting "F5". I got an exception:...
4
7016
by: Tyro | last post by:
Can someone shed some light on my error here? Thanks! Specified cast is not valid. Exception Details: System.InvalidCastException: Specified cast is not valid. Source Error: Stack Trace:
3
10492
by: PK9 | last post by:
I am looking for assistance in pinpointing the cause of the following exception. I am getting a "Specified Cast is not valid" exception on my page. I am trying to populate a datagrid. One of my...
2
3078
by: Fabian | last post by:
Hi, I work with asp.net 2.0 and I have a intermittent error, only happens a few times a day. In the page I evaluate a Query String and then I get data form a database. The code snipped: ...
3
2165
by: VB Programmer | last post by:
I am setting up forms authentication. In my code I keep getting this error. Any ideas? Error.... Server Error in '/LandOLots' Application....
0
623
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
0
1597
by: Alan Z. Scharf | last post by:
this question in datagrid group for several days with no repsonse. I'm hoping for an answer her because of greater activity in this group. No cross-posting intended. Thanks....
8
4245
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
3
12409
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
2
8730
by: vinrin | last post by:
Thank for your answer. :-) call CheckEmptyNode (treeview) public void CheckEmptyNode( Object N ) { Microsoft.Web.UI.WebControls.TreeNode menuNode = null; ...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.