Solved

CheckBox code behind

Posted on 2007-11-20
9
332 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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