Solved

CheckBox code behind

Posted on 2007-11-20
9
331 Views
Last Modified: 2013-11-07
Hi. I have a Datagrid with 2 check box columns, one is Match From and the other is Match to. When a user selects a any row from match From column the rest of the check boxes within that row will be disabled including the one next to it. The user will be able to click in the Match To column for multiple checks. I also have a Match button. After selecting what is needed within the relevant check boxes the user must click the Match button. When the user clicks the Match button, the info from the Match From column(only the clicked items) button must change to the info that is in the Match To row. Currently I have a Javascript the can do the enabiling and disabiling. What I need to know is how am I going to write the code behind for when you click the Match Button.
0
Comment
Question by:B1SA
  • 5
  • 4
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20321026
You need to add an attribute for the OnClick event handler:

OnClick="Button1_Click"

Bob
0
 

Author Comment

by:B1SA
ID: 20325542
Yes I did that. I need the code for the Match Button. For when the User click on it, it can match the relevent data to the relevent clients.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20327108
Oh, you want to know what to put in the button click event handler.  You can cast the 'sender' into a Button, and then get parent information to determine the DataGrid item that you are working with, and then use FindControl to get a reference to any other controls for the current item, and then transfer values from one control to another.

Bob
0
 

Author Comment

by:B1SA
ID: 20327188
Here is the code that I have for the Match Button. It's not working properly. Can you help?  

Private Sub btnMatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMatch.Click
        Try
            Dim row As DataGridItem
            Dim SqlHelper As SqlHelper
            Dim MyDataSet3 As DataSet = Nothing
            Dim connection As SqlConnection = New SqlConnection
            Dim SuppParams() As SqlParameter = New SqlParameter(4) {}
            Dim vsVendors As String = ""
            Dim oSessionInfo As SessionManager = New SessionManager
            Dim ds As DataSet = Nothing
            Dim vlfkCompanyID

            SuppParams(0) = New SqlParameter("@VendorCoID", SqlDbType.Int)
            SuppParams(0).Value = vlfkCompanyID


            connection.ConnectionString = Configuration.ConfigurationSettings.AppSettings("ConnectionString")
            MyDataSet3 = SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, "spSingleVendorMatchSearch", SuppParams)

            For Each row In dgSearch.Items
                Dim chkbx As CheckBox = row.FindControl("chkItemChecked")
                If chkbx.Checked = True Then
                    vsVendors = vsVendors & row.Cells(0).Text & " ,"
                End If
            Next

        Catch ex As Exception
            Throw ex
        End Try

    End Sub
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 20327214
Try this, and let me know what you get:

Dim btnMatch As Button = CType(sender, Button)
Dim parentType As String = btnMatch.Parent.GetType().Name
Dim grandParentType As String = btnMatch.Parent.Parent.GetType().Name

Bob
0
 

Author Comment

by:B1SA
ID: 20327336
Can you please write the whole code or should I put this snippet in my code?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20327349
Put that in the btnMatch_Click event:

Private Sub btnMatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMatch.Click

Dim btnMatch As Button = CType(sender, Button)
Dim parentType As String = btnMatch.Parent.GetType().Name
Dim grandParentType As String = btnMatch.Parent.Parent.GetType().Name

...

Bob
0
 

Author Comment

by:B1SA
ID: 20327451
Must I put the connection string to the DB? Sorry but I am blonde and stupid today.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 50 total points
ID: 20327474
Now, that is a change of gears (GRIND)!!

Configuration.ConfigurationSettings.AppSettings("ConnectionString")

I would use this instead:

    ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString

That would mean that the connection string would need to be in the <connectionStrings> section in the config file.

Bob
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

861 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

Need Help in Real-Time?

Connect with top rated Experts

30 Experts available now in Live!

Get 1:1 Help Now