can this be done?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
CsharpGuy said:
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.
 
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/
 
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
 
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/
 
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/
 
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?
 
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/
 
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...

???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top