Hello,
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidC astException: Specified cast is not valid.
Line 176.
Source Error:
Line 174:
Line 175:
Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ;
Line 177:
Line 178: System.Web.UI.W ebControls.Imag e thumb =
(System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" );
Can somebody help me?
Thanks! 10 1784
You're casting a "DataItem" as a "DataRowVie w" - that's an invalid cast!!
hehehe - I know I sound like your error, but it's true. You can't pretend a
DataItem is a DataRowView..
"Arjen" <bo*****@hotmai l.com> wrote in message
news:bh******** **@news1.tilbu1 .nb.home.nl... Hello,
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidC astException: Specified cast is not
valid. Line 176.
Source Error:
Line 174: Line 175: Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; Line 177: Line 178: System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" );
Can somebody help me?
Thanks!
And now?
"Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht
news:eU******** **************@ newssvr28.news. prodigy.com... You're casting a "DataItem" as a "DataRowVie w" - that's an invalid cast!! hehehe - I know I sound like your error, but it's true. You can't pretend
a DataItem is a DataRowView..
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... Hello,
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidC astException: Specified cast is not valid. Line 176.
Source Error:
Line 174: Line 175: Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; Line 177: Line 178: System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" );
Can somebody help me?
Thanks!
And now, you still can't. You can only coerce a variable to pretend it's a
different type - when they are close enough..
In the same way you couldn't do this:
TreeView objMyTree = (TreeView)strSo meString;
You can't cast things that are vastly different. There is no way to coerce a
string into representing a TreeView.
"Arjen" <bo*****@hotmai l.com> wrote in message
news:bh******** **@news1.tilbu1 .nb.home.nl... And now?
"Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht news:eU******** **************@ newssvr28.news. prodigy.com... You're casting a "DataItem" as a "DataRowVie w" - that's an invalid
cast!! hehehe - I know I sound like your error, but it's true. You can't
pretend a DataItem is a DataRowView..
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... Hello,
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidC astException: Specified cast is not valid. Line 176.
Source Error:
Line 174: Line 175: Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; Line 177: Line 178: System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" );
Can somebody help me?
Thanks!
Put a breaking point at DataRowView drv = (DataRowView) e.Item.DataItem ;
Then Do a Quick Watch on e.item.DataItem or find the type of e.item.DataItem
and see what type it is
Then cast to that type
"Arjen" <bo*****@hotmai l.com> wrote in message
news:bh******** **@news1.tilbu1 .nb.home.nl... And now?
"Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht news:eU******** **************@ newssvr28.news. prodigy.com... You're casting a "DataItem" as a "DataRowVie w" - that's an invalid
cast!! hehehe - I know I sound like your error, but it's true. You can't
pretend a DataItem is a DataRowView..
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... Hello,
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidC astException: Specified cast is not valid. Line 176.
Source Error:
Line 174: Line 175: Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; Line 177: Line 178: System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" );
Can somebody help me?
Thanks!
Here is the complete function:
private void myDataGrid_Item DataBound(objec t sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem) {
DataRowView drv = (DataRowView) e.Item.DataItem ;
System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge)
e.Item.FindCont rol("thumbnail" );
thumb.Attribute s.Add("OnClick" , "SelectImag e('" + drv["itemId"].ToString()
+ "')");
}
}
May be this helps.
"MS News (MS ILM)" <sq**********@h otmail.com> schreef in bericht
news:up******** ******@TK2MSFTN GP09.phx.gbl... Put a breaking point at DataRowView drv = (DataRowView)
e.Item.DataItem ; Then Do a Quick Watch on e.item.DataItem or find the type of
e.item.DataItem and see what type it is Then cast to that type
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... And now?
"Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht news:eU******** **************@ newssvr28.news. prodigy.com... You're casting a "DataItem" as a "DataRowVie w" - that's an invalid cast!! hehehe - I know I sound like your error, but it's true. You can't pretend a DataItem is a DataRowView..
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... > Hello, > > Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information > about the error and where it originated in the code. > > Exception Details: System.InvalidC astException: Specified cast is
not valid. > Line 176. > > Source Error: > > > Line 174: > Line 175: > Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; > Line 177: > Line 178: System.Web.UI.W ebControls.Imag e thumb = > (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" ); > > > Can somebody help me? > > Thanks! > >
I *think* in that scenario - that e is actually your DataRowView..
Set a breakpoint and add a watch to 'e' and see what it is, if it is a
DataRowView then you can just reference things as:
e["itemId"].ToString()
hth
"Arjen" <bo*****@hotmai l.com> wrote in message
news:bh******** **@news1.tilbu1 .nb.home.nl... Here is the complete function: private void myDataGrid_Item DataBound(objec t sender, System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == ListItemType.Al ternatingItem) {
DataRowView drv = (DataRowView) e.Item.DataItem ;
System.Web.UI.W ebControls.Imag e thumb =
(System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" ); thumb.Attribute s.Add("OnClick" , "SelectImag e('" +
drv["itemId"].ToString() + "')");
} } May be this helps.
"MS News (MS ILM)" <sq**********@h otmail.com> schreef in bericht news:up******** ******@TK2MSFTN GP09.phx.gbl... Put a breaking point at DataRowView drv = (DataRowView) e.Item.DataItem ; Then Do a Quick Watch on e.item.DataItem or find the type of e.item.DataItem and see what type it is Then cast to that type
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... And now?
"Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht news:eU******** **************@ newssvr28.news. prodigy.com... > You're casting a "DataItem" as a "DataRowVie w" - that's an invalid cast!! > hehehe - I know I sound like your error, but it's true. You can't pretend a > DataItem is a DataRowView.. > > "Arjen" <bo*****@hotmai l.com> wrote in message > news:bh******** **@news1.tilbu1 .nb.home.nl... > > Hello, > > > > Description: An unhandled exception occurred during the execution
of the > > current web request. Please review the stack trace for more information > > about the error and where it originated in the code. > > > > Exception Details: System.InvalidC astException: Specified cast is not > valid. > > Line 176. > > > > Source Error: > > > > > > Line 174: > > Line 175: > > Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; > > Line 177: > > Line 178: System.Web.UI.W ebControls.Imag e thumb = > > (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" ); > > > > > > Can somebody help me? > > > > Thanks! > > > > > >
string thetype = e.Item.DataItem .GetType();
What do you get
"Arjen" <bo*****@hotmai l.com> wrote in message
news:bh******** **@news1.tilbu1 .nb.home.nl... When I change it to e["itemId"].ToString(). VS says: Cannot apply indexing with [] to an expression of type 'System.Web.UI. WebControls.Dat aGridItemEventA rgs'
The debug says: object DataGridItem.Da teItem Gets or sets the data item represented by the System.Web.UI.W ebControls.Data GridItem object in the System.Web.UI.W ebControls.Data Grid
I don't know what to do now... you? Thanks!
"Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht news:sj******** **************@ newssvr28.news. prodigy.com... I *think* in that scenario - that e is actually your DataRowView..
Set a breakpoint and add a watch to 'e' and see what it is, if it is a DataRowView then you can just reference things as:
e["itemId"].ToString()
hth
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... Here is the complete function: private void myDataGrid_Item DataBound(objec t sender, System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == ListItemType.Al ternatingItem) {
DataRowView drv = (DataRowView) e.Item.DataItem ;
System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" ); thumb.Attribute s.Add("OnClick" , "SelectImag e('" + drv["itemId"].ToString() + "')");
} } May be this helps.
"MS News (MS ILM)" <sq**********@h otmail.com> schreef in bericht news:up******** ******@TK2MSFTN GP09.phx.gbl... > Put a breaking point at DataRowView drv = (DataRowView) e.Item.DataItem ; > Then Do a Quick Watch on e.item.DataItem or find the type of e.item.DataItem > and see what type it is > Then cast to that type > > > "Arjen" <bo*****@hotmai l.com> wrote in message > news:bh******** **@news1.tilbu1 .nb.home.nl... > > And now? > > > > > > > > > > > > "Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht > > news:eU******** **************@ newssvr28.news. prodigy.com... > > > You're casting a "DataItem" as a "DataRowVie w" - that's an
invalid > cast!! > > > hehehe - I know I sound like your error, but it's true. You
can't > pretend > > a > > > DataItem is a DataRowView.. > > > > > > "Arjen" <bo*****@hotmai l.com> wrote in message > > > news:bh******** **@news1.tilbu1 .nb.home.nl... > > > > Hello, > > > > > > > > Description: An unhandled exception occurred during the execution of > the > > > > current web request. Please review the stack trace for more > information > > > > about the error and where it originated in the code. > > > > > > > > Exception Details: System.InvalidC astException: Specified cast is not > > > valid. > > > > Line 176. > > > > > > > > Source Error: > > > > > > > > > > > > Line 174: > > > > Line 175: > > > > Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; > > > > Line 177: > > > > Line 178: System.Web.UI.W ebControls.Imag e thumb = > > > > (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" ); > > > > > > > > > > > > Can somebody help me? > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > >
> I *think* in that scenario - that e is actually your DataRowView.
"e" is an instance of DataGridItemEve ntArgs. "e.Item" is the member to look
at. It can be one of several possible types, such as a heading section, a
footer section, or a data row. However, setting a breakpoint and doing a
watch should indeed revela what e.Item is.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer http://www.takempis.com
Neither a follower nor a lender be.
"Frank Drebin" <no*****@imsick ofspam.com> wrote in message
news:sj******** **************@ newssvr28.news. prodigy.com... I *think* in that scenario - that e is actually your DataRowView..
Set a breakpoint and add a watch to 'e' and see what it is, if it is a DataRowView then you can just reference things as:
e["itemId"].ToString()
hth
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... Here is the complete function: private void myDataGrid_Item DataBound(objec t sender, System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType == ListItemType.Al ternatingItem) {
DataRowView drv = (DataRowView) e.Item.DataItem ;
System.Web.UI.W ebControls.Imag e thumb = (System.Web.UI. WebControls.Ima ge) e.Item.FindCont rol("thumbnail" ); thumb.Attribute s.Add("OnClick" , "SelectImag e('" + drv["itemId"].ToString() + "')");
} } May be this helps.
"MS News (MS ILM)" <sq**********@h otmail.com> schreef in bericht news:up******** ******@TK2MSFTN GP09.phx.gbl... Put a breaking point at DataRowView drv = (DataRowView) e.Item.DataItem ; Then Do a Quick Watch on e.item.DataItem or find the type of e.item.DataItem and see what type it is Then cast to that type
"Arjen" <bo*****@hotmai l.com> wrote in message news:bh******** **@news1.tilbu1 .nb.home.nl... > And now? > > > > > > "Frank Drebin" <no*****@imsick ofspam.com> schreef in bericht > news:eU******** **************@ newssvr28.news. prodigy.com... > > You're casting a "DataItem" as a "DataRowVie w" - that's an invalid cast!! > > hehehe - I know I sound like your error, but it's true. You can't pretend > a > > DataItem is a DataRowView.. > > > > "Arjen" <bo*****@hotmai l.com> wrote in message > > news:bh******** **@news1.tilbu1 .nb.home.nl... > > > Hello, > > > > > > Description: An unhandled exception occurred during the
execution of the > > > current web request. Please review the stack trace for more information > > > about the error and where it originated in the code. > > > > > > Exception Details: System.InvalidC astException: Specified cast
is not > > valid. > > > Line 176. > > > > > > Source Error: > > > > > > > > > Line 174: > > > Line 175: > > > Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; > > > Line 177: > > > Line 178: System.Web.UI.W ebControls.Imag e thumb = > > > (System.Web.UI. WebControls.Ima ge)
e.Item.FindCont rol("thumbnail" ); > > > > > > > > > Can somebody help me? > > > > > > Thanks! > > > > > > > > > > > >
"Arjen" <bo*****@hotmai l.com> wrote Line 176: DataRowView drv = (DataRowView) e.Item.DataItem ; I use now a datagrid and the IBS a datalist.
Some body else a solution?
Arjen,
If you use a DataSet to bind the DataList, then that is the correct syntax.
However, if you use a SqlDataReader to bind, then you must cast the
DataItem to a System.Data.Com mon.DbDataRecor d.
e.g.
System.Data.Com mon.DbDataRecor d dbDataRecord =
(System.Data.Co mmon.DbDataReco rd) e.Item.DataItem ;
String s = dbDataRecord.Ge tString(0);
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP http://www.able-consulting.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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: "Specified cast is not valid."
The only thing i put there was a "test this." inside the form. What
might be the problem here?
Thanks in advance.
The Exception:
|
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:
|
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 columns is a template
column where I'd like to evaluate the data brought back from the db and
populate the column with a "Y" or "N" depending on the value in the db. Here
is the code that is causing it as well as the error (below).
ERROR...
|
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:
try
{
|
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.
--------------------------------------------------------------------------------
| |
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
not
valid.","Microsoft.BusinessIntelligence.Scorecard.ScorecardException:
Specified cast is not valid. --->
Microsoft.BusinessIntelligence.Scorecard.ScorecardException: Specified
cast is not valid. ---> System.InvalidCastException: Specified...
|
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.
-----------------------------------------------------------
Server
VS.NET 2003
SQLServer 2000
IIS 66.0
|
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 not
valid"). How do I fix it ?
using System.Diagnostics;
..
..
class NewProcess: Process
{
|
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:
======================
Message: Specified cast is not valid.
Type: System.InvalidCastException
Source: System.Data.Linq
TargetSite: Boolean TryCreateKeyFromValues(System.Object, V ByRef)
|
by: vinrin |
last post by:
Thank for your answer. :-)
call CheckEmptyNode (treeview)
public void CheckEmptyNode( Object N )
{
Microsoft.Web.UI.WebControls.TreeNode menuNode = null;
Microsoft.Web.UI.WebControls.TreeNode iNode = null;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |