473,473 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

about Checkbox !!

Hi all,
i have a question about checkbox.
i made a form, with some textboxes, and buttons..
the idea is this..
i want to enter some information (like name, address..) and some hobbies !
i made the hobbies as a checkboxes.. so the user check the ones apply..
then i made a "SAVE" button, to add this whole info to a arraylist,
i put a "back" and "next" buttons to navigate records..
it worked perfectly for the names and addresses ! (when i click back, it
shows the previous data object with its info)
but, the problem is.. i cant retrieve the checkbox condition !
i used this code to stor data :

private ArrayList GetHobbies()
{
if (mCheckBoxWalking.Checked)
Hobbies.Add("Walking");
if (mCheckBoxSwimming.Checked)
Hobbies.Add("Swimming");
if (mCheckBoxReading.Checked)
Hobbies.Add("Reading");
return Hobbies;
}

and i tried to retrive the use information by this code :

void GetUser(UserInformation user)
{
mTextboxName.Text = user.Name; // to get the name
mTextboxAddress.Text = user.Address; // to get the adderss
if (user.Hobbies.ToString() == "Walking")
mCheckBoxWalking.Checked = true;
if (user.Hobbies.ToString() == "Swimming")
mCheckBoxSwimming.Checked = true;
if (user.Hobbies.ToString() == "Reading")
mCheckBoxReading.Checked = true;
}
as i said, the name and address worked.
but the checkbox is not !
plz some help here ! :)
and thanx in advance..
--
Eng. Rushd R. Momani
Jul 2 '07 #1
7 1276
Hi,

How are you storing the hobbies?

That is the key to solve your problem.

"rushd" <ru*******@hotmail.comwrote in message
news:B7**********************************@microsof t.com...
Hi all,
i have a question about checkbox.
i made a form, with some textboxes, and buttons..
the idea is this..
i want to enter some information (like name, address..) and some hobbies !
i made the hobbies as a checkboxes.. so the user check the ones apply..
then i made a "SAVE" button, to add this whole info to a arraylist,
i put a "back" and "next" buttons to navigate records..
it worked perfectly for the names and addresses ! (when i click back, it
shows the previous data object with its info)
but, the problem is.. i cant retrieve the checkbox condition !
i used this code to stor data :

private ArrayList GetHobbies()
{
if (mCheckBoxWalking.Checked)
Hobbies.Add("Walking");
if (mCheckBoxSwimming.Checked)
Hobbies.Add("Swimming");
if (mCheckBoxReading.Checked)
Hobbies.Add("Reading");
return Hobbies;
}

and i tried to retrive the use information by this code :

void GetUser(UserInformation user)
{
mTextboxName.Text = user.Name; // to get the name
mTextboxAddress.Text = user.Address; // to get the adderss
if (user.Hobbies.ToString() == "Walking")
mCheckBoxWalking.Checked = true;
if (user.Hobbies.ToString() == "Swimming")
mCheckBoxSwimming.Checked = true;
if (user.Hobbies.ToString() == "Reading")
mCheckBoxReading.Checked = true;
}
as i said, the name and address worked.
but the checkbox is not !
plz some help here ! :)
and thanx in advance..
--
Eng. Rushd R. Momani

Jul 2 '07 #2
at first thnx for ur reply,
2nd, i made a new ArrayList:
ArrayList Hobbies = new ArrayList();
then i made a function (Type arraylist) called GetHobbies, and i used it to
get the user hobbies, the function :

private ArrayList GetHobbies()
{
if (mCheckBoxWalking.Checked)
Hobbies.Add("Walking");
if (mCheckBoxSwimming.Checked)
Hobbies.Add("Swimming");
if (mCheckBoxReading.Checked)
Hobbies.Add("Reading");
return Hobbies;
}

so, when u click "save" in form.. it calls the GetHobbies function:
user.Hobbies = GetHobbies();

so all, of the hobbies Which was selected, will be added to the Hobbies
ArrayList by using GetHobbies() (ADD)..

this is how i store the hobbies..
but still, when i retrieve them, it do nothing !
i debugged the code step by step, and when it reaches the lines (in
GetUser() function) :

if (user.Hobbies.ToString() == "Walking")
mCheckBoxWalking.Checked = true;
if (user.Hobbies.ToString() == "Swimming")
mCheckBoxSwimming.Checked = true;
if (user.Hobbies.ToString() == "Reading")
mCheckBoxReading.Checked = true;

it just do nothing (as if the "IF" condition is false !) but its true!
im working on this code since 4 days !
i just don't know whats wrong :/

--
Eng. Rushd R. Momani
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

How are you storing the hobbies?

That is the key to solve your problem.
Jul 2 '07 #3
rushd wrote:
Hi all,
i have a question about checkbox.
i made a form, with some textboxes, and buttons..
the idea is this..
i want to enter some information (like name, address..) and some hobbies !
i made the hobbies as a checkboxes.. so the user check the ones apply..
then i made a "SAVE" button, to add this whole info to a arraylist,
i put a "back" and "next" buttons to navigate records..
it worked perfectly for the names and addresses ! (when i click back, it
shows the previous data object with its info)
but, the problem is.. i cant retrieve the checkbox condition !
i used this code to stor data :

private ArrayList GetHobbies()
{
if (mCheckBoxWalking.Checked)
Hobbies.Add("Walking");
if (mCheckBoxSwimming.Checked)
Hobbies.Add("Swimming");
if (mCheckBoxReading.Checked)
Hobbies.Add("Reading");
return Hobbies;
}

and i tried to retrive the use information by this code :

void GetUser(UserInformation user)
{
mTextboxName.Text = user.Name; // to get the name
mTextboxAddress.Text = user.Address; // to get the adderss
if (user.Hobbies.ToString() == "Walking")
mCheckBoxWalking.Checked = true;
if (user.Hobbies.ToString() == "Swimming")
mCheckBoxSwimming.Checked = true;
if (user.Hobbies.ToString() == "Reading")
mCheckBoxReading.Checked = true;
}
as i said, the name and address worked.
but the checkbox is not !
plz some help here ! :)
and thanx in advance..
Hi,

Your problem is you're performing the tests wrong. You're looking at the
result of calling ToString on the arraylist, which is not what you want.

The following code should work:

///
if (user.Hobbies.Contains("Walking"))
mCheckBoxWalking.Checked = true;
///

And you can easily extend it to your other cases.

What's going on here is that you're *interrogating* the list to check for
the presence of an item, what you were doing before wasn't checking the
list.
--
Tom Spink
University of Edinburgh
Jul 2 '07 #4
"Tom Spink" wrote:
Hi,

Your problem is you're performing the tests wrong. You're looking at the
result of calling ToString on the arraylist, which is not what you want.

The following code should work:

///
if (user.Hobbies.Contains("Walking"))
mCheckBoxWalking.Checked = true;
///

And you can easily extend it to your other cases.

What's going on here is that you're *interrogating* the list to check for
the presence of an item, what you were doing before wasn't checking the
list.
--
Tom Spink
University of Edinburgh
thanks :) it worked (partially) !
but thanks any way! its now like 80% done.. :)
when i save like 10 records, and i press "Back".. it shows me the last
checkbox was checked (which is right).. or if i press "First" (which takes me
to the 1st data record) it shows me the checkbox for the 1st Data record
(which is also right)
but, the problem now is this.. when i press "back" again.. the checkbox
state remains as is ! (showing the 10th data record) so, i retrieve only one
checkbox state.
any ideas !?
Jul 3 '07 #5
Rushd wrote:
"Tom Spink" wrote:
>Hi,

Your problem is you're performing the tests wrong. You're looking at the
result of calling ToString on the arraylist, which is not what you want.

The following code should work:

///
if (user.Hobbies.Contains("Walking"))
mCheckBoxWalking.Checked = true;
///

And you can easily extend it to your other cases.

What's going on here is that you're *interrogating* the list to check for
the presence of an item, what you were doing before wasn't checking the
list.
--
Tom Spink
University of Edinburgh

thanks :) it worked (partially) !
but thanks any way! its now like 80% done.. :)
when i save like 10 records, and i press "Back".. it shows me the last
checkbox was checked (which is right).. or if i press "First" (which takes
me to the 1st data record) it shows me the checkbox for the 1st Data
record (which is also right)
but, the problem now is this.. when i press "back" again.. the checkbox
state remains as is ! (showing the 10th data record) so, i retrieve only
one checkbox state.
any ideas !?
Hi,

Without further implementation details, I can only speculate as to what's
happening. Can you provide more information about how you're storing the
hobbies in the array list, and how you're storing them for each user?

--
Tom Spink
University of Edinburgh
Jul 3 '07 #6
ok !sorry.. it works now :)
i had one arraylist for all of the users :s
i put the arraylist definition inside the "save" method, so now it makes new
arraylist for each new data record.. it works 100% now :)
thanks a lot
Jul 3 '07 #7
Rushd wrote:
ok !sorry.. it works now :)
i had one arraylist for all of the users :s
i put the arraylist definition inside the "save" method, so now it makes
new arraylist for each new data record.. it works 100% now :)
thanks a lot
Excellent. I'm glad you got it sorted.

--
Tom Spink
University of Edinburgh
Jul 3 '07 #8

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

Similar topics

2
by: Fred | last post by:
Hi, I defined a form consisting of checkboxes like: <form> <input type="checkbox" name=ck id=ck onclick="check(this.form)" <input type="checkbox" name=ck id=ck onclick="check(this.form)" ........
7
by: Gui Lloyd | last post by:
I have a problem with performance in IE. The script above works quite fine when the table has a small number of elements, but, when the table has 2500 elements, when I click in the checkbox of the...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
0
by: Albert Smith via .NET 247 | last post by:
Hi all. I have a dataset with a datatable. I have a form and a checkbox binded to a boolean field of my datatable. When i check or uncheck my checkbox the binded row gets updated. My problem...
0
by: Joseph S. | last post by:
hi all, debugging PHP applications interactively is possible, easy and free. I am talking about PHPEclipse and using it for debugging over several scripts or debugging through a session. Since I...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
4
by: ATDave | last post by:
So basically I'm just creating a form that I want the results e-mailed to somebody. I have everything working except for the checkmark sections that can have multiple answers. I'm a newbie when...
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
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
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...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.