[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

pass value from Checkbox in a Class

Posted on 2012-12-28
10
Medium Priority
?
361 Views
Last Modified: 2012-12-31
I want to put one of my functions in a class.  However, I am not sure on how to pass checkbox value?


public function UpdateData(byval id as interger, byval chkbAmount as ????) as Boolean      
dim TF as boolean = false
Using con As New SqlConnection(WebConfigurationManager.ConnectionStrings("myConnectionString").ToString)
                con.Open()
                Using comnd As New SqlCommand("mysp", con)
                    comnd.CommandType = Data.CommandType.StoredProcedure
                    comnd.Parameters.AddWithValue("@id", id)
                    comnd.Parameters.AddWithValue("@accountnumber", txtaccountnumber)
             
                    If chkbAmount.Checked = True Then                                <<<<< this line
                        comnd.Parameters.AddWithValue("@noupdate", "Y")
                    Else
                        comnd.Parameters.AddWithValue("@noupdate", "")
                    End If
                    comnd.ExecuteNonQuery()
                  tf = true
                 
                End Using
            End Using
return tf
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38728228
Why not just set the parameter type to be Boolean, and then pass the chkbAmount.Checked value to the function call?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38728230
Change

public function UpdateData(byval id as interger, byval chkbAmount as ????) as Boolean  

to

public function UpdateData(byval id as interger, byval chkbAmount as Boolean) as Boolean  


Then pass it chkbAmount.Checked
0
 

Author Comment

by:VBdotnet2005
ID: 38728429
Somethinkg like this?

ClassUpdate

public function UpdateData(byval id as interger, byval chkbAmount  Boolean) as Boolean      
dim TF as boolean = false
Using con As New SqlConnection(WebConfigurationManager.ConnectionStrings("myConnectionString").ToString)
                con.Open()
                Using comnd As New SqlCommand("mysp", con)
                    comnd.CommandType = Data.CommandType.StoredProcedure
                    comnd.Parameters.AddWithValue("@id", id)
                    comnd.Parameters.AddWithValue("@accountnumber", txtaccountnumber)
             
                    If chkbAmount  = True Then                                                    comnd.Parameters.AddWithValue("@noupdate", "Y")
                    Else
                        comnd.Parameters.AddWithValue("@noupdate", "")
                    End If
                    comnd.ExecuteNonQuery()
                  tf = true
                 
                End Using
            End Using
return tf


from page


dim Update_test as new ClassUpdate
dim test as boolean = update_test.UpdateData(id, ???) <<< checkbox is on page, how would I know if True or false?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38728432
>checkbox is on page, how would I know if True or false?

Check its .Checked property. Is it on page or within some other container control such as grid?
0
 

Author Comment

by:VBdotnet2005
ID: 38728434
It is on a form. Like this?
dim Update_test as new ClassUpdate
dim test as boolean = update_test.UpdateData(id, chkbAmount.checked) ???
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38728444
Yes.
0
 

Author Comment

by:VBdotnet2005
ID: 38728452
Not like this?

dim chkb_tmp as boolean = false
if chkbAmount.checked then
   chkb_tmp = true
end
dim Update_test as new ClassUpdate
dim test as boolean = update_test.UpdateData(id, chkb_tmp) ???


dim test as boolean = update_test.UpdateData(id, chkbAmount.checked) <<< I would not know in advace if chkbAmount is checked
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38728458
Have you tried anything yet?

chkbAmount.Checked will tell you whether its checked or not. You don't have to know that.
0
 

Author Comment

by:VBdotnet2005
ID: 38728462
I just did tried it. Sorry, just a bit confused. Thank you very much codeCruiser
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38728491
Glad to help :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question