473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can this be done?

on my web form I have a checkbox for the user to check or not. How can I pass
the value of the checkbox to my business layer to execute the correct SQL
statement?
I need to run seperate sql queries based on if the checkbox is checked on my
web form or not. So is it possible to pass the checkbox value to my datalayer
class?

Mar 1 '06 #1
9 919
"CsharpGuy" <Cs*******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
on my web form I have a checkbox for the user to check or not. How can I
pass
the value of the checkbox to my business layer to execute the correct SQL
statement?
I need to run seperate sql queries based on if the checkbox is checked on
my
web form or not. So is it possible to pass the checkbox value to my
datalayer
class?


I'm not exactly certain what your problem is... An <asp:CheckBox> control
has a boolean Checked property - interrogate that when the page is posted
back, and branch your code accordingly.
Mar 1 '06 #2
do something like the following

public void GetChecked(bool isChecked)
{
if (isChecked == true)
// do code for checked
else
// do code for unchecked
}

then, you call the following

GetChecked(CheckBox.Checked);

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 1 '06 #3
I know how to get the value, but its not passing to my datalayer.

i have this on my form
if (chkBox.checked == true)
{
callDataLayer();
}

then in my datalayer I need to get that value and "trap it" and run the
correct SQL query in a method in my datalayer

"Mark Rae" wrote:
"CsharpGuy" <Cs*******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
on my web form I have a checkbox for the user to check or not. How can I
pass
the value of the checkbox to my business layer to execute the correct SQL
statement?
I need to run seperate sql queries based on if the checkbox is checked on
my
web form or not. So is it possible to pass the checkbox value to my
datalayer
class?


I'm not exactly certain what your problem is... An <asp:CheckBox> control
has a boolean Checked property - interrogate that when the page is posted
back, and branch your code accordingly.

Mar 1 '06 #4
callDataLayer(chkBox.checked);

???
Mar 1 '06 #5
what are you returning? you would want something like this

[public|protected|private] [datatype] callDataLayer(bool isChecked)
{
// logic to perform
}

from what you had, it looks like it would be a void, so something like
this would work
public void callDataLayer(bool isChecked)
{
// code
}

then you would call the method with what you had, although in c#
Checked needs to be caps, for
callDataLayer(chkBox.Checked);

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 1 '06 #6
what are you returning? you would want something like this

[public|protected|private] [datatype] callDataLayer(bool isChecked)
{
// logic to perform
}

from what you had, it looks like it would be a void, so something like
this would work
public void callDataLayer(bool isChecked)
{
// code
}

then you would call the method with what you had, although in c#
Checked needs to be caps, for
callDataLayer(chkBox.Checked);

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 1 '06 #7
should the GetChecked be in the datalayer or no?
Thats where I'm stuck at because i have a method in the dl that will run 1
of 2 queries based on the checkbox value
so how would the dl get that value of the checkbox?

"Darren Kopp" wrote:
do something like the following

public void GetChecked(bool isChecked)
{
if (isChecked == true)
// do code for checked
else
// do code for unchecked
}

then, you call the following

GetChecked(CheckBox.Checked);

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 1 '06 #8
I would have that in the datalayer, yes. Basically, you pass the value
of the checkbox through the Checked property. The checked property
gets or sets a boolean value, so when you pass it, it passes a boolean
value, which your data layer is expecting. It doesn't see it as a
checkbox or checked, it sees it as true or false. in your data layer,
you say

if (isChecked == true)
// generate 1 sql statement
else
// generate a different sql statement

-Darren Kopp
http://blog.secudocs.com/

Mar 1 '06 #9
"CsharpGuy" <Cs*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I know how to get the value, but its not passing to my datalayer.

i have this on my form
if (chkBox.checked == true)
{
callDataLayer();
}

then in my datalayer I need to get that value and "trap it" and run the
correct SQL query in a method in my datalayer


??? So pass it into your callDataLayer() method as an argument, e.g.

callDataLayer(chkBox.checked);

Then modify the callDataLayer function to accept a boolean parameter e.g.

public void callDataLayer(bool bChecked)
{
if(bChecked)
{
// do something
}
else
{
// do something else
}
}

I still don't really see what your problem is... Pass the value of your
checkbox into your datalayer and then take action as appropriate... This
really nothing to do with ASP.NET per se - it's just basic programming...

???
Mar 2 '06 #10

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

Similar topics

0
1672
by: itsharkopath | last post by:
Hi, Imagine a user in a hotspot, when he comes to the hotspot and tries to load a webpage (on the internet), he would automatically redirected to login page. I believe the following is to be...
9
1709
by: Steven T. Hatton | last post by:
This was written for the gnu.g++.help list. It rather clearly spells out the most important feature of Java that I believe C++ lacks. I really don't believe the C++ Standard sepcifies enough for a...
16
2931
by: jaialai technology | last post by:
I want to reload a url in a browser window so I do something like this: open(window.location.href= "www.yahoo.com"); ok, so now I want to do something when that page is done loading completely....
5
1378
by: Morten Overgaard | last post by:
Hi I have a C# component which fires events. I want to catch these events in my MFC app compiled with the /clr. I know I can define a managed class in my MFC app which traps the events - but I...
11
17805
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
3
1374
by: Miguel Dias Moura | last post by:
Hi, When I subscribe a web site I usually receive an email to confirm my subscription. Only after I follow the link in the email my account gets activated. In general, how is this done? Can...
4
1414
by: BrianDH | last post by:
Group Early this week I ask for examples on how to call a VB.NET Web Service and access its DataSet for a traditional ASP page. I was told, "you can't", "won't work", "not possible". Well I...
12
2605
by: Ark | last post by:
Hello NG, I arrange data in structs like { members... uint16_t crc; more members, maybe... } Then I need to save them, up to and including crc, in non-volatile memory or a file, as the case...
2
1872
by: maya | last post by:
http://news.yahoo.com/news?tmpl=index2&cid=703 down the page, under "More Stories", there's a section with two interchangeable divs which slide back and forth into view.. how is this done? I...
2
3366
by: poolboi | last post by:
hey guys, i've done most of my web app. for searching almost done but then i got a small little problem with logging in i need to know how session tracking is done in perl if not my log in page...
0
7298
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,...
0
7366
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...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
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
5610
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
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
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
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.