473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1794
Joe
Never mind

"Joe" <jb*******@noemail.noemailwrote in message
news:%2****************@TK2MSFTNGP03.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*******@noemail.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*******@noemail.noemailwrote in message
news:%2****************@TK2MSFTNGP03.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 10 '07 #3

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

Similar topics

0
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)....
11
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...
9
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...
1
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...
8
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...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - When should I use eval? ----------------------------------------------------------------------- The ` eval() `...
3
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='<%#...
10
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...
1
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.