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

C# Form Processing: If Exists

I have several different variations of the same form. Some include an asp
Radio Button list option called rb_monthly. If that option exists I need to
do some extra processing on the form.
The following works on the pages with the option :
if(rb_monthly != null)
{
monthly = rb_monthly.SelectedValue;
}

When the option's not there it doesn't work and I get compiler errors as
rb_monthly doesn't exist.
I've tried this:
string valMonthly = findVals("rb_monthly");
if (valMonthly != "")
{
monthly = valMonthly;
}
and some variations thereof, and while that doesn't cause compiler error it
also doesn't get the value and fails to process a later section of the code
that is supposed to process if monthly is true.

There has gotta be some way to do some sort of if exists check but I'm
mostly a newbie and am working off code I have been given.
Any help is majorly appreciated!!!
Thanks
Matthew Loraditch

Nov 21 '07 #1
2 1047
Check for null, as well, as a string can be null. That is quite common,
especially when pulling from a keyed list, like the ASP.NET form or
querystring collections.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"Matthew Loraditch" <ml********@yahoo.comwrote in message
news:59**********************************@microsof t.com...
>I have several different variations of the same form. Some include an asp
Radio Button list option called rb_monthly. If that option exists I need to
do some extra processing on the form.
The following works on the pages with the option :
if(rb_monthly != null)
{
monthly = rb_monthly.SelectedValue;
}

When the option's not there it doesn't work and I get compiler errors as
rb_monthly doesn't exist.
I've tried this:
string valMonthly = findVals("rb_monthly");
if (valMonthly != "")
{
monthly = valMonthly;
}
and some variations thereof, and while that doesn't cause compiler error
it also doesn't get the value and fails to process a later section of the
code that is supposed to process if monthly is true.

There has gotta be some way to do some sort of if exists check but I'm
mostly a newbie and am working off code I have been given.
Any help is majorly appreciated!!!
Thanks
Matthew Loraditch

Nov 21 '07 #2
Sorry for the newb questions.
Right now I am doing this, but as I previously mentioned, it only works if
the rb_monthly is on the page:
if(rb_monthly != null)
{
monthly = rb_monthly.SelectedValue;
}
Are you saying do this?
if (rb_monthly == null)
{
monthly =false;
} else{
monthly = rb_monthly.SelectedValue;
}

Thanks again,
Matthew

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:#Y**************@TK2MSFTNGP02.phx.gbl...
Check for null, as well, as a string can be null. That is quite common,
especially when pulling from a keyed list, like the ASP.NET form or
querystring collections.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
"Matthew Loraditch" <ml********@yahoo.comwrote in message
news:59**********************************@microsof t.com...
>>I have several different variations of the same form. Some include an asp
Radio Button list option called rb_monthly. If that option exists I need
to do some extra processing on the form.
The following works on the pages with the option :
if(rb_monthly != null)
{
monthly = rb_monthly.SelectedValue;
}

When the option's not there it doesn't work and I get compiler errors as
rb_monthly doesn't exist.
I've tried this:
string valMonthly = findVals("rb_monthly");
if (valMonthly != "")
{
monthly = valMonthly;
}
and some variations thereof, and while that doesn't cause compiler error
it also doesn't get the value and fails to process a later section of the
code that is supposed to process if monthly is true.

There has gotta be some way to do some sort of if exists check but I'm
mostly a newbie and am working off code I have been given.
Any help is majorly appreciated!!!
Thanks
Matthew Loraditch

Nov 22 '07 #3

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

Similar topics

1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
7
by: RC | last post by:
When I am adding records to a database and each record is unique by the Serial Number. I would like to step through my code adding records unless the Serial Number already exists in the database. ...
13
by: Ioannis Vranos | last post by:
Why in this code the form *does not refresh* when it gets the focus/after some time? #using <mscorlib.dll> #using <system.windows.forms.dll> #using <system.dll> #using <system.drawing.dll>
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
3
by: raj chahal | last post by:
Hi there i have created a registration page containing a form than sends username password to an asp processing page. If the user exists it sends the user back to the registration page with...
2
by: AJang | last post by:
My windows form "Form1" has one Button "button1" and one TextBox "textBox1". When I click button1, it do a job for each file in a directory. The job include some platform invoke call. Before...
10
by: Jake Forson | last post by:
Hi there, I'd like to re-create a form given only its resource file. I was going to simply read the resource file and re-create the "Form" object and all its controls as found in this file...
1
by: Victory | last post by:
i am using the Shown event for a form. It is in .NET 2.0. It is an event that occurs when a form is displayed. I wanted to use this event since i needed the processing of data to occur after the...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
2
by: Matthew Loraditch | last post by:
I have several different variations of the same form. Some include an asp Radio Button list option called rb_monthly. If that option exists I need to do some extra processing on the form. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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: 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:
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,...

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.