I have a class method which takes integer as parameter...when i call the
method as shown below i get this error message: Specified cast is not valid
<td><%# bs.getPriority((int)DataBinder.Eval(Container.Data Item,
"Priority"))%></td>
When i print the DataItem "Priority" it shows an integer value, but for some
reason the method does not like value.. if i call this method like ->
bs.getPriortiy(3); it works fine.
In the database i have a field called "Priority" int type...
The method works fine when i call it in DataItemBound method..
any idea? 5 2014
Hi,
Try using
int.Parse(DataBinder.Eval(Container.DataItem, "Priority"))
DataBinder.Eval returns a string value type. (int) is used to
implicitly cast values to integers. Strings must be explicitly cast
using the Parse method.
Hope this helps.
Tod Birdsall, MCP http://tod1d.blogspot.com
Tod thank you so much :) it worked..
still confused why one of them works not the other as shown below:
<TD><%# bs.getCampusName((int)DataBinder.Eval(Container.Da taItem,
"CampusID"))%></TD>
<td><%# bs.getCampusName((int.Parse(DataBinder.Eval(Contai ner.DataItem,
"Priority")))%></td>
both CampusID and Priority is same type of value..
Many Thanks again.
"Tod Birdsall" wrote: Hi,
Try using
int.Parse(DataBinder.Eval(Container.DataItem, "Priority"))
DataBinder.Eval returns a string value type. (int) is used to implicitly cast values to integers. Strings must be explicitly cast using the Parse method. Hope this helps.
Tod Birdsall, MCP http://tod1d.blogspot.com
Sorry that did not solve the problem... :( i am getting this error message
now:
The best overloaded method match for 'int.Parse(string)' has some invalid
arguments
"Tod Birdsall" wrote: Hi,
Try using
int.Parse(DataBinder.Eval(Container.DataItem, "Priority"))
DataBinder.Eval returns a string value type. (int) is used to implicitly cast values to integers. Strings must be explicitly cast using the Parse method. Hope this helps.
Tod Birdsall, MCP http://tod1d.blogspot.com
Acutally, DataBinder.Eval returns an object unless you pass a third
parameter, a format specifier, i.e.
DataBinder.Eval(Container.DataItem, "Priority", "{0:d}")
Otherwise you get an object reference back, in which case you could
use Convert.ToInt32
--
Scott http://www.OdeToCode.com/blogs/scott/
On Tue, 9 Nov 2004 07:38:03 -0800, "huzz"
<hu**@discussions.microsoft.com> wrote: Sorry that did not solve the problem... :( i am getting this error message now:
The best overloaded method match for 'int.Parse(string)' has some invalid arguments
"Tod Birdsall" wrote:
Hi,
Try using
int.Parse(DataBinder.Eval(Container.DataItem, "Priority"))
DataBinder.Eval returns a string value type. (int) is used to implicitly cast values to integers. Strings must be explicitly cast using the Parse method. Hope this helps.
Tod Birdsall, MCP http://tod1d.blogspot.com
Hi,
Scott is correct. Sorry for the mis-information.
I tried to reproduce your error message. I created a function in the
code behind like so:
protected string GetRemainderInEscrow(decimal approvedAmount, object
paidAmount)
I then called the method from the aspx page using the following code :
<%# GetRemainderInEscrow( (decimal)DataBinder.Eval(Container,
"DataItem.ApprovedAmount"), DataBinder.Eval(Container, "DataItem.Paid")
) %>
The code worked as it should. If you have control over the
'bs.getPriority' method, try allowing an object to be passed instead of
an integer value type. If that doesn't work. If that still does not
work, copy and paste the exact error message and Stack Trace.
Tod Birdsall, MCP http://tod1d.blogspot.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rob Ristroph |
last post by:
Hi,
It's pretty unhelpful to post "I have a huge piece of code that
crashes in strange places, what's the problem?" but that's basically
my problem and I really am at my wit's end.
The piece...
|
by: Paul Drummond |
last post by:
Hi all,
I am developing software for Linux Redhat9 and I have noticed some very
strange behaviour when throwing exceptions within a shared library.
All our exceptions are derived from...
|
by: Neil Ginsberg |
last post by:
I have a strange situation with my Access 2000 database. I have code in the
database which has worked fine for years, and now all of a sudden doesn't
work fine on one or two of my client's...
|
by: TB |
last post by:
I am seeing a very strange problem as follows...
I have a loop where a fair amount of processing is going on and near
the top of the loop I access a class that has only static helper
functions...
|
by: Sam Kong |
last post by:
Hello!
Recently I had a strange problem with Visual C# 2005 beta 1.
When I ran(F5 key) a program, <#if DEBUG> statement was not working.
It ran as RELEASE mode.
So I had to manually define...
|
by: Spam Trap |
last post by:
I am getting strange resizing problems when using an inherited form.
Controls are moving themselves seemingly randomly, but reproducibly.
"frmBase" is my base class (a windows form), and...
|
by: Martin Joergensen |
last post by:
Hi,
I've encountered a really, *really*, REALLY strange error :-)
I have a for-loop and after 8 runs I get strange results...... I
mean: A really strange result....
I'm calculating...
|
by: StephQ |
last post by:
I have a class Bounds with two constructors:
class Bounds
{
private:
list<SegmentupperLinearSpline; // Upper bound.
list<SegmentlowerLinearSpline; // Lower bound.
....
|
by: Dox33 |
last post by:
I ran into a very strange behaviour of raw_input().
I hope somebody can tell me how to fix this.
(Or is this a problem in the python source?)
I will explain the problem by using 3 examples....
|
by: ioni |
last post by:
Good day, fellows!
I have a strange problem – at my site there is a flash strip, that
loads data dynamically.
It works fine (grabs data from the remote server and presents it),
however in IE7...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
| |