473,324 Members | 1,646 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,324 software developers and data experts.

How do I test for null or empty value?

jm
I have a dropdownlist.

In my page_load I have:

myvariable as integer
myvariable = myddl.selectedvalue

I get "Input string was not in a correct format."

The I know my data and it is supposed to be a number. In reality,
however, because this is a fresh load (not a postback), the value is
empty for the selectedvalue and it is causing the error. I have to
have this load in the nonpostback. Since the value of the
dropdownlist is empty, nothing, or null, how do I test for this? I
cannot find it. Thank you.
Nov 18 '05 #1
2 4068
if(blah != null)
{
}
BUT, you may simply want to only have the value read if it's a postback....
if(IsPostBack())
{
.....get values
}
else
{
....dont....
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om...
I have a dropdownlist.

In my page_load I have:

myvariable as integer
myvariable = myddl.selectedvalue

I get "Input string was not in a correct format."

The I know my data and it is supposed to be a number. In reality,
however, because this is a fresh load (not a postback), the value is
empty for the selectedvalue and it is causing the error. I have to
have this load in the nonpostback. Since the value of the
dropdownlist is empty, nothing, or null, how do I test for this? I
cannot find it. Thank you.

Nov 18 '05 #2
Problem is you may not assign a Null (SelectedValue when nothing is
selected) to an integer variable

You may do

If myddl.SelectedIndex <> -1 Then ' something is selected
myvariable = myddl.SelectedValue
End If

Regards
Jose

"jm" <jo*************@yahoo.com> escribió en el mensaje
news:c6**************************@posting.google.c om...
I have a dropdownlist.

In my page_load I have:

myvariable as integer
myvariable = myddl.selectedvalue

I get "Input string was not in a correct format."

The I know my data and it is supposed to be a number. In reality,
however, because this is a fresh load (not a postback), the value is
empty for the selectedvalue and it is causing the error. I have to
have this load in the nonpostback. Since the value of the
dropdownlist is empty, nothing, or null, how do I test for this? I
cannot find it. Thank you.

Nov 18 '05 #3

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

Similar topics

4
by: Cyrus D. | last post by:
Hi guys, What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST; if(strlen($test) < 1) // it is empty ! Maybe I can just go:
2
by: FizzBin | last post by:
We are writing a C application that is using ODBC to insert records into a database. We have a NOT NULL column that can legitimately have an empty value, i.e. we know the value and it is empty...
4
by: n_o_s_p_a__m | last post by:
My xml doc has many <title></title> and <title> in it, meaning the nodes have no content (although some do). How can I test for this? I tried title (doesn't work) I tried //title (doesn't work)...
4
by: chirs | last post by:
I try to test a field to see if it's empty. But it prints "It is not null". Why and how can I fix it? <html> <head> </head> <body> <input type="text" name="box1"> <script>
7
by: Gertjan van Heijst | last post by:
Hi, I really hope someone can help me because I've already spend 2 days on this problem and I'm not getting anywhere. I think the problem is that I don't really understand how text boxes store...
6
by: EDOnLine | last post by:
New asp.net/webform user question...... I am trying to use the Custom Validator control to check to see if either of two fields on my form have been filled in. At this point all I am interested...
5
by: Little | last post by:
I have this program and I need to work on the test portion, which tests if a Val is in the list. It returns false no matter what could you look at the part and see what might need to be done to fix...
3
by: AAJ | last post by:
Hi all A quick question on Datasets..... I populate a dataset from a SQL SERVER 2000 database via a data adapter. I then use the dataset to populate member variables of my class. I know the...
7
by: kumar.senthil | last post by:
Hi, I'm using XmlSerializer to create an object from the XML string. I would like to know whether I can get a null value for an empty XML element. Actually the XmlSerializer assigns "" (empty...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.