|
You should set set it to false. Boolean is supposed to hold either true or false.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
If he's going to be grabbing the value from a database, null could be a "valid" entry.
|
|
|
|
|
There is always that possibility. But based on his reply to this post, I am not sure if that's the case.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Then you can use DBNull. That's the whole reason that class exists.
|
|
|
|
|
The problem is that the application is already built to use boolean values. The user has a section where they chose an option from two drop down boxes. Based on what they select there are two check boxes that are either enabled or not. The user wants to see the results of these choices in the reporting as true equal yes and false equaling no and if it is not enabled they want it to show a blank.
the way that it is designed right now is it uses a findcontrol on the check boxes, which returns true or false no matter if it is enabled or not. It then takes that true/false and puts it into the database table. I first thought to just put the assignment into an if statement checking to see if it is enabled. If not then I would not assign anything to that value in the table. This will work for the first time creation of this but the user can go back later and change their answers and this will not change the value that is in the table.
|
|
|
|
|
I can think of some situation where I might really want a boolean, but to know that it hasn't been initialized yet. Nullable boolean makes sense sometimes.
|
|
|
|
|
Here is part of the code that I am talking about:
CheckBox chkPU = (CheckBox)dgi.FindControl(c_grd_ctrl_id_chkPU);
CheckBox chkCP = (CheckBox)dgi.FindControl(c_grd_ctrl_id_chkCP);
.
.
.
.
vudr.INCL_PERS_USE_IND = chkPU.Checked;
vudr.COMN_CRY_PSGR_IND = chkCP.Checked;
|
|
|
|
|
ltmnm wrote: it is not enabled
If it is the checkbox that you are talking about, then you have to check the enabled property if it is true or false. If you need to have the dropdown show a blank when the checkbox is not enabled, then you just need to add the logic to check for that. Don't confuse Checked property with Enabled ...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Sorry, I should be more clear. The drop down boxes are just answers that go into the database. the code also checks to see if the check boxes are checked and then stores that in the database as well. It returns false when the check box is not checked even if the check box is not enabled. The data that is in the table is then queried and used for reporting services. In those reports the user wants to see yes when the check box is checked and no when it is not. They also want to see just a blank for when the check box was not enabled. So, I am just trying to see if there is a way to make a boolean value equal true, false and anything else that could represent the check box not being enabled.
Hope that helps clear things up a little.
thank you for all your help.
|
|
|
|
|
The only way you can represent the checkbox not being enabled is testing for CheckBox.Enabled = false ...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
right, that's why I tried this:
if(chkPU.Enabled)
vudr.INCL_PERS_USE_IND = chkPU.Checked;
else
vudr.INCL_PERS_USE_IND = null;
problem is that this: vudr.INCL_PERS_USE_IND is expecting a boolean value.
I wanted to see if there was an easy way to make this happen to assign any other value other than true or false.
I guess I will have to start re-coding everything to use a diff value.
|
|
|
|
|
Hello,
I think the only way to make it clear is to change the type to "int" could be easyly used as an enum also!
Or if this is not possible for you, you have to add an additional bool value!
All the best,
Martin
All the best,
Martin
|
|
|
|
|
Take a look at Martin#'s suggestion. It sounded like to me you needed to populate the dropdowns, there's probably many ways to achieve what you are trying to do.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
to store three possible states one boolean is clearly insufficient.
they invented boolean? for this when C# 2.0 was launched
but I would also consider using a pair of booleans, one for hasValue, one for value.
that seems the most logical approach in your case.
Anyhow, you need to make sure the three states somehow get stored in the DB too.
|
|
|
|
|
There is a clear semantic difference between null and false . null typically represents unknown information.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Here is what I have, I want to display in a new window or in the same form (on the right hand side) after a item in a listbox (which is located on the top-left side)is clicked.
How do I go about doing this?
Thanks.
|
|
|
|
|
Leverage the Click event for the list box. In the event code, you can grab the item selected, and act upon it.
Use the ListBox.SelectedValue property to decide what was clicked. (assuming you limit your box to a single selection)
Hogan
|
|
|
|
|
Like snorkie said, you have to have a button that on the click it goes to the new form and passes the selected value from the listbox to the new form.
To prevent global variable ugliness, pass the selected value as a parameter in the constructor of the new form.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I am using WSE 3.0 to create a TCP web service.
Everything was working fine until I referenced some classes from a separate dll.
The proxy class generates fine and includes the classes from the separate dll.
The problem is when the client calls the webservice with a calls that results in using
classes from the separate dll the client throws an exception saying that I am using
an object from an unreferenced dll.
How to you reference this dll to make the client happy?
|
|
|
|
|
Your client is probably receiving the message error from the server. So, I believe the solution is not in changing the client.
Try to copy the DLL to the BIN folder in your WebService and see if it works.
Charles.
|
|
|
|
|
Thanks for your reply.
It turns out that the problem was related to two different sets of similar classes.
The code was using some objects from one set of classes and some from the other.
The generated proxy code was all messed up thus confusing the client.
Once we removed the duplicate (proof of concept) set of classes everything worked as expected.
|
|
|
|
|
Hello,
I'm having a trouble with the 2.0 Framework method FTP.ListDirectory.
I'm writing an application which creates a file by executing an http command, then verify if the file exists on the server and downloads it. The problem is that the list of files returned by Ftp.ListDirectory doesn't change even if the file is created(I can see it with a graphical FTP client).
Sometimes it works and I get the list of all files. But it seems to me if I make many consecutive requests, the files list isn't refreshed any more as if it was stored in a cache....
Can you help me to fix it?
Thanks.
|
|
|
|
|
Are these files hidden or system files?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
thanks for replying.
The directory listed by the code has only .zip files. I even can see them in my graphical FTP client. So my answer is no, files aren't hidden.
|
|
|
|
|
Hi,
I think the I have the answer to this post. I'm not really sure but so far I've done many consecutive tests and the results of the response always changes if new files are created.
It's about the cache policy and this is the way to set it.
System.Net.FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(param);
request.CachePolicy = new System.Net.Cache.RequestCachePolicy =(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
|
|
|
|