Solved

CheckBox code behind

Posted on 2007-11-20
9
335 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
[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
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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 …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

628 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