Welcome to Dream.In.Code
Become an Expert!

Join 150,064 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,778 people online right now. Registration is fast and FREE... Join Now!




ASP.NET and VB.NET: problem with GridView's "disabled" b

 
Reply to this topicStart new topic

ASP.NET and VB.NET: problem with GridView's "disabled" b

trosoft
29 Feb, 2008 - 03:26 AM
Post #1

New D.I.C Head
*

Joined: 24 Feb, 2008
Posts: 5



Thanked: 1 times
My Contributions

I have pulled data from SQL Server into a GridView control.
Two of the columns are checkbox fields.

During run-time,I am to click those columns to enter a check.
But how can I find out if the values of those items during run-tim

I need to allow the user to indicate whether they approve or deny a request; and then, I shall be able to update the corresponding columns in the originating database table.

What must I do to solve this problem?

During run-time, I added these two columns to the already existing ones:

CODE


Dim myCol1 As New DataColumn("Approved")
Dim myCol2 As New DataColumn("Denied")

myCol1.DataType = System.Type.GetType("System.Boolean")

myCol2.DataType = System.Type.GetType("System.Boolean")

myDataSet.Tables(0).Columns.Add(myCol1...
myDataSet.Tables(0).Columns.Add(myCol2...
myDataSet.Tables(0).AcceptChanges()


I have code in myGridView_RowUpdating():

CODE


       Try      
            'For Each column As GridViewRow In myGridView.Rows(myGridView.EditIndex)
            ' Access the CheckBox
            'Dim cb As CheckBox = column.FindControl("Approved")

            'Perhaps could also check to see if the index of the row equals myGridView.EditIndex
            For Each row As GridViewRow In myGridView.Rows
                ' Access the CheckBox
                Dim cb As CheckBox = row.FindControl("Approved")


                If cb IsNot Nothing AndAlso cb.Checked Then
                    Console.WriteLine("Found")

                    'Here, I want to see if the Approved checkbox is checked.

                End If
            Next
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try



This is the code that I placed in myGridView_RowCommand():

CODE

    
       Static intCount As Integer
        Dim intRowIndex As Integer


'If intCount = 0 Then
        intRowIndex = CInt(e.CommandArgument.ToString())
        'dim intColumnIndex as Integer = cint(Request.Form(["__EVENTARGUMENT"])

        myGridView.EditIndex = intRowIndex    'Place this particular row of the GridView control in edit mode.

        intCount += 1
        'End If  'If intCount = 0

        Dim intResponse As Integer
        Dim strAnswered As String


        If (e.CommandName.Equals("Edit")) Then

        ElseIf (e.CommandName.Equals("Update")) Then
            Console.WriteLine("Update")

            ' If myGridView.Rows(intRowIndex).Cells.Item("2").ToString And myGridView.Rows(intRowIndex).Cells.Item("2").Text Then

            ' End If

            'intResponse = MsgBox("Are you sure that you want to approve this request?", MsgBoxStyle.YesNoCancel, "Confirmation Required")
        ElseIf (e.CommandName.Equals("Cancel")) Then

        Else
            'Nada
        End If  'If (e.CommandName.Equals("Edit"))

        If intResponse = vbCancel Then
            MsgBox("The record has not been changed.", MsgBoxStyle.OkOnly, "No Action Taken")


            Exit Sub
        End If

        If intResponse = vbYes Then
            'Retreive the value of the key

            Dim strKey As String


            'strKey = myGridView.DataKeys(intRowIndex).Values(0).ToString    'Oops! There has been nothing assigned to DataKeys.

            'Note: myGridView.Rows(intRowIndex).Cells.Item(0).Text is "", since it is the column of DELETE buttons.

            'This gives the contents of the first row, first column. It would have been Cells.Item(0), had it not been
            ' displaced by the row of EDIT buttons.
            strKey = myGridView.Rows(intRowIndex).Cells.Item(1).Text

            'Call the handling routine, with strKey as a parameter.
            'SupervisorResponse(strKey)
        End If  'If intResponse = vbYes


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:43PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month