473,661 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compile error

LL
Hi,

How to fix this problem:

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.

Source Error:
Line 138: </ItemTemplate>
Line 139: <EditItemTempla te>
Line 140: <asp:CheckBox id=edit_Status runat="server" Checked='<%#
DataBinder.Eval (Container.Data Item, "Status")%> '>
Line 141: </asp:CheckBox>
Line 142: </EditItemTemplat e>

Nov 15 '05 #1
13 3314
"LL" <li*******@hotm ail.com> wrote in
news:eN******** ******@TK2MSFTN GP09.phx.gbl:
Hi,

How to fix this problem:

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.

Source Error:
Line 138: </ItemTemplate>
Line 139: <EditItemTempla te>
Line 140: <asp:CheckBox id=edit_Status runat="server"
Checked='<%# DataBinder.Eval (Container.Data Item, "Status")%> '>
Line 141: </asp:CheckBox>
Line 142: </EditItemTemplat e>


probably your StatusField isn'T of Type bool?

if it is nummeric (0,1) you could do this:
Checked='<%# 1==DataBinder.E val(Container.D ataItem, "Status")%> '>

if it'S text ("true", "false") you could do this:

Checked='<%# "true" == DataBinder.Eval (Container.Data Item, "Status")%> '>

I guess you got the idea ...
--
best regards

Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at
Nov 15 '05 #2
LL
Hi,

If I change to GetSelectedInde x(1) , then it works.
Please help me on this error:
Specified cast is not valid.
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.

Source Error:
Line 131:
Line 132:<EditItemTe mplate>
Line 133: <asp:DropDownLi st id=edit_AdminRi ghts runat="server"
SelectedIndex=' <%# GetSelectedInde x((int)DataBind er.Eval(Contain er.DataItem,
"AdminRight s")) %>'>
Line 134: <asp:ListItem Value="0" Selected="True" >Read
Only</asp:ListItem>
Line 135: <asp:ListItem Value="1">Read/Edit</asp:ListItem>
Source File: C:\Project\test \Maintenance.as px Line: 133

"Peter Koen" <koen-newsreply&snusn u.at> wrote in message
news:uW******** ******@TK2MSFTN GP11.phx.gbl...
"LL" <li*******@hotm ail.com> wrote in
news:eN******** ******@TK2MSFTN GP09.phx.gbl:
Hi,

How to fix this problem:

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.

Source Error:
Line 138: </ItemTemplate>
Line 139: <EditItemTempla te>
Line 140: <asp:CheckBox id=edit_Status runat="server"
Checked='<%# DataBinder.Eval (Container.Data Item, "Status")%> '>
Line 141: </asp:CheckBox>
Line 142: </EditItemTemplat e>


probably your StatusField isn'T of Type bool?

if it is nummeric (0,1) you could do this:
Checked='<%# 1==DataBinder.E val(Container.D ataItem, "Status")%> '>

if it'S text ("true", "false") you could do this:

Checked='<%# "true" == DataBinder.Eval (Container.Data Item, "Status")%> '>

I guess you got the idea ...
--
best regards

Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at

Nov 15 '05 #3
LL <li*******@hotm ail.com> wrote:
If I change to GetSelectedInde x(1) , then it works.
Please help me on this error:
Specified cast is not valid.


That suggests that DataBinder.Eval (Container.Data Item,"AdminRigh ts")
isn't returning an integer. Try writing to the debug log:

DataBinder.Eval (Container.Data Item,"AdminRigh ts").GetType( )

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4
LL
Thanks Jon.

It's 'Byte'.
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
LL <li*******@hotm ail.com> wrote:
If I change to GetSelectedInde x(1) , then it works.
Please help me on this error:
Specified cast is not valid.


That suggests that DataBinder.Eval (Container.Data Item,"AdminRigh ts")
isn't returning an integer. Try writing to the debug log:

DataBinder.Eval (Container.Data Item,"AdminRigh ts").GetType( )

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #5
That would make a great movie title....."Once Byte en"
"LL" <li*******@hotm ail.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
Thanks Jon.

It's 'Byte'.
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
LL <li*******@hotm ail.com> wrote:
If I change to GetSelectedInde x(1) , then it works.
Please help me on this error:
Specified cast is not valid.


That suggests that DataBinder.Eval (Container.Data Item,"AdminRigh ts")
isn't returning an integer. Try writing to the debug log:

DataBinder.Eval (Container.Data Item,"AdminRigh ts").GetType( )

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 15 '05 #6
LL <li*******@hotm ail.com> wrote:
It's 'Byte'.


Right. In that case, you need to either cast to byte, and all should be
well.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #7
Yes it will heal if you put a cast on it. It will get well.


"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
LL <li*******@hotm ail.com> wrote:
It's 'Byte'.


Right. In that case, you need to either cast to byte, and all should be
well.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #8
LL
Hi,

How to fix this one:
(int) ((ListBox)E.Ite m.FindControl(" edit_" + "AdminRights")) .SelectedValue
error: '(int)' cannot be performed on '"0"'

How to get the
SelectedValue?

Thanks again.


"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
LL <li*******@hotm ail.com> wrote:
It's 'Byte'.


Right. In that case, you need to either cast to byte, and all should be
well.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #9
LL <li*******@hotm ail.com> wrote:
How to fix this one:
(int) ((ListBox)E.Ite m.FindControl(" edit_" + "AdminRights")) .SelectedValue
error: '(int)' cannot be performed on '"0"'

How to get the
SelectedValue?


Well I'd start by making your code more readably in the first place -
if you break that single line up into several, chances are it'll become
obvious.

That seems a strange compilation error to me, but SelectedValue returns
a string, not an integer. You'll need to use Int32.Parse or
Convert.ToInt32 in order to convert a string to an integer.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #10

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

Similar topics

4
2222
by: Danny Boelens | last post by:
Hi all, today I ran into a compile error after a compiler upgrade. I made a small example to demonstrate my compile error: template<typename T1, typename T2> class A {}; class B
5
3324
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new rightType;
5
3808
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace ) Person.xsd includes Common-Naming.xsd ( anonimous schemas ) Common-Naming.xsd includes common.xsd ( both are anonimous schemas ) Compilation of Resident.xsd raise the following exception: "System.Xml.Schema.XmlSchemaException: The attribute 'oid'...
10
19708
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I have a struct that contains several different types of data. This struct is used throuout the program. Now, when I compile, I get 6 errors, all of them "Use of possibly unassigned field 'awayTime'" or "Use of possibly unassigned field 'intlTime'"....
6
2848
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked fine while the file was in the project directory. When the obsolete file was removed from the project directory, my application will no longer compile. Can someone please help with this issue? Thank in advance, Tom
0
1898
by: Jim Heavey | last post by:
Internal Compiler Error: stage 'BEGIN' Hello, I had an application which was working just fine and I decided to modify all database access within the application to utilizie a new Namespace that I had developed which would handle all database access. After I modified all of the code to point to the new namespace and created all of the necessary references, I get an internal compile error when I attempt to re-compile. I have create a new...
9
3505
by: ThunderMusic | last post by:
Hi, I'd like to create a compile time error in my class... maybe there's a way already built in in the framework so I can achieve what I want... I have 2 constructors in my class. One of them has mandatory parameters, I mean, they should not be null nor empty (for strings). So I'd make the validation in the constructor and generate a compile-time error if the validation does not match... Is there a way to achieve this or to specify...
4
1839
by: tony | last post by:
Hello! My question is about calling this method CollectData below but I get a compile error that I shouldn't have because the type parameter is correct. The compile error is the following: C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracApplication\Dialog\Composit ionForm.cs(942): Argument '1': cannot convert from 'ref MeltPracData.MeltPracDataComposition' to 'ref MeltPracCommon.IDialogPostData'
5
5039
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
2
4131
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error message is: E:\software\development\boost_1_35_0\boost_1_35_0>bjam -- toolset=msvc-7.1 --variant=release --threading=multi --link=shared --
0
8432
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, 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...
0
8855
Oralloy
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...
0
8758
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 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...
0
8633
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 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...
0
7364
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
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...
1
2762
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
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.