Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CheckBox code behind

Posted on 2007-11-20
9
Medium Priority
?
338 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
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.

 

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
 
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 100 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

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 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