473,397 Members | 2,099 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,397 software developers and data experts.

Passing Null to Function ?

I have defined custom binding in DetailView Textbox.

<%# ShowParent(Eval("ParentID")) %>

Its calling a ShowParent() function which is as under:
The problem is that if ParentID field is Null,then the above line passes the
Null to function and error occurs when converting DBNull to Int16.

How can I detect if ParentID is Null or not ?
Function ShowParent(byVal parentID as Int16) as String

'my code

End Sub
Best Regards,

Luqman


Apr 23 '07 #1
2 1116
On Apr 23, 3:08 pm, "luqman" <pearls...@cyber.net.pkwrote:
I have defined custom binding in DetailView Textbox.

<%# ShowParent(Eval("ParentID")) %>

Its calling a ShowParent() function which is as under:

The problem is that if ParentID field is Null,then the above line passes the
Null to function and error occurs when converting DBNull to Int16.

How can I detect if ParentID is Null or not ?

Function ShowParent(byVal parentID as Int16) as String

'my code

End Sub

Best Regards,

Luqman
Try to pass an object to the function

Function ShowParent(byVal parentID) as String

and check there

If Not IsDbNull(parentID) then
Dim parentID_int as Int16 = Convert.ToInt16(parentID)
....
End If

Apr 23 '07 #2
My first thought is switching to a nullable type (available in 2.0). The
type would be short? in C#, changing the signature to:

ShowParent(short? val)

This may still not work, as the issue may not be in the parameter.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*********************************************
Think outside the box!
*********************************************
"luqman" <pe*******@cyber.net.pkwrote in message
news:ee**************@TK2MSFTNGP04.phx.gbl...
>I have defined custom binding in DetailView Textbox.

<%# ShowParent(Eval("ParentID")) %>

Its calling a ShowParent() function which is as under:
The problem is that if ParentID field is Null,then the above line passes
the
Null to function and error occurs when converting DBNull to Int16.

How can I detect if ParentID is Null or not ?
Function ShowParent(byVal parentID as Int16) as String

'my code

End Sub
Best Regards,

Luqman

Apr 23 '07 #3

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

Similar topics

4
by: Pushkar Pradhan | last post by:
I want a function to execute another function, which I pass to it, sometimes it may be mm_6r6c_6r6c, mm_2r2c_2r2c, ... etc. thus this style. double exec_basecase(void (*func)(double *a, double...
2
by: Morgan | last post by:
Thanks to all of you because I solved the problem related with my previous post. I simply made confusion with pointers to pointers and then succeeded passing the reference to the first element...
5
by: Bucky Pollard | last post by:
I am calling a PVCS DLL function from C#. According to the documentation, I can pass NULL to any output parameter that I do not want to receive data back for. How do I do this? Every thing I've...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
7
by: Jake Thompson | last post by:
Hello I created a DLL that has a function that is called from my main c program. In my exe I first get a a pointer to the address of the function by using GetProcAddress and on the dll side I...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
12
by: Mike | last post by:
Consider the following code: """ struct person { char *name; int age; }; typedef struct person* StructType;
8
by: Ivan Liu | last post by:
Hi, I'd like to ask if passing an object as an pointer into a function evokes the copy constructor. Ivan
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
18
by: sanjay | last post by:
Hi, I have a doubt about passing values to a function accepting string. ====================================== #include <iostream> using namespace std; int main() {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
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...
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
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,...
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...
0
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...
0
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,...
0
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...

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.