Solved

CheckBox code behind

Posted on 2007-11-20
9
330 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
Comment Utility
You need to add an attribute for the OnClick event handler:

OnClick="Button1_Click"

Bob
0
 

Author Comment

by:B1SA
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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
Comment Utility
Can you please write the whole code or should I put this snippet in my code?
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

10 Experts available now in Live!

Get 1:1 Help Now