473,715 Members | 6,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Eval returning a null when an int is expected

Joe
I'm binding to a column in a TemplateField. In some cases the join I have
returns a null for an int field. I would like to specify a default value
somehow so I don't end up with a null exception.

I'm binding the CurrentRating of the Rating control so I'm doing
Convert.ToInt32 (Eval('MyField' )). This of course throws an exception if the
value being returned is null.

Is there another means of binging to that property where either a null
doesn't matter or I can replace it with a 0?

Thanks,
Joe
Dec 7 '07 #1
2 1804
Joe
Never mind

"Joe" <jb*******@noem ail.noemailwrot e in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
I'm binding to a column in a TemplateField. In some cases the join I have
returns a null for an int field. I would like to specify a default value
somehow so I don't end up with a null exception.

I'm binding the CurrentRating of the Rating control so I'm doing
Convert.ToInt32 (Eval('MyField' )). This of course throws an exception if
the value being returned is null.

Is there another means of binging to that property where either a null
doesn't matter or I can replace it with a 0?

Thanks,
Joe

Dec 7 '07 #2
Hi Joe,

Just some suggestions for databinding:

in the <%# %expression, you can use helper function, for example:

Property='<%# MyFunction(Eval ("propertyname" )) %>'

this function can be defined in aspx inline or in code behind. Such
function can let you do some complex formating or customization on the raw
databound value.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Joe" <jb*******@noem ail.noemail>
References: <#4************ **@TK2MSFTNGP03 .phx.gbl>
Subject: Re: Eval returning a null when an int is expected
Date: Fri, 7 Dec 2007 17:55:52 -0500

Never mind

"Joe" <jb*******@noem ail.noemailwrot e in message
news:%2******* *********@TK2MS FTNGP03.phx.gbl ...
>I'm binding to a column in a TemplateField. In some cases the join I
have
>returns a null for an int field. I would like to specify a default value
somehow so I don't end up with a null exception.

I'm binding the CurrentRating of the Rating control so I'm doing
Convert.ToInt3 2(Eval('MyField ')). This of course throws an exception if
the value being returned is null.

Is there another means of binging to that property where either a null
doesn't matter or I can replace it with a 0?

Thanks,
Joe


Dec 10 '07 #3

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

Similar topics

0
4270
by: Bryan Jackson | last post by:
Greetings, (I am an Oracle newbie -- been working with SQLServer for quite some time, however. I'm using Oracle9i and Oracle9i JDeveloper v9.0.3.1 (build 1107) for my programming environment). I'm trying to get an Oracle function to return XML to a JSP page, but am having some problems (mostly Oracle errors). Let me start by showing you what I've done so far.
11
1879
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before the use of eval() is required to execute it?" Given the following code, I'm able to evaluate/execute most expressions like: "a.b.c.d()"
9
5209
by: Thomas Mlynarczyk | last post by:
Hi, It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of? Greetings, Thomas
1
1706
by: anonymous.user0 | last post by:
Whats the common/best practice for returning a "Does not exist/not found" result from a function. Imagine I've got a function: myObjectType GetById(long id); where the object may or may not be found. Currently, I just return a null. But this muddies up the calling code with null checks and stuff. Example: I've got an Appoinment class, that has a property Doctor of class Doctor. This property is lazily loaded, so I only store the...
8
9268
by: fredo | last post by:
This question was asked in comp.lang.javascript with no result. In IE5.x and IE6, I want to display an image when the user rolls over a text link. The image does indeed display, but only on the first rollover. It seems that the image height and width become set to zero after the image is displayed once; or perhaps that the height:expression(eval(...)); code is executed only once for each page load/reload. problem demo:
8
2214
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - When should I use eval? ----------------------------------------------------------------------- The ` eval() ` function should _only_ be used when it is necessary to evaluate a string supplied or composed at run-time; the string can be anything from a simple (but unpredictable) expression such as 12*2.54 to a substantial piece of javascript code. The `...
3
10578
by: Kevin Blount | last post by:
I'm putting a radG:GridTemplateColumn together (which is probably irelevant), and within it I'm using a Label, as so: <asp:Label ID="defaultDescription" runat="server" Text='<%# Eval("description") %>'></asp:Label> Fo this Label, I'd like to only show the first 50 chars of the "description", but I've no idea how to change the Eval to do this.. is there a way?
10
494
by: Gordon | last post by:
I have a script that creates new objects based on the value of a form field. Basically, the code looks like this. eval ('new ' + objType.value + '(val1, val2, val3'); objType is a select with the different types of objects you can create as values. I really don't like using eval, and it's causing problems, like if I do something like the following:
1
2676
by: bizt | last post by:
Hi, Im currently looking to move into using JSON for AJAX instead of returning from the server a string like the following: 12345{This is a text string{true I prefer objects because I dont need to specifiy the index key and I can treat it exactly like an array - oSet = ... Are objects just as quick to access/alter as arrays? I have a few
0
9343
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
9198
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...
1
9104
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
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
7973
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
6646
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
5967
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();...
1
3175
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
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.