This is a migrated thread and some comments may be shown as answers.

GridViewCheckBoxColumn - check value while iterating through grid rows

2 Answers 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Gone2TheDogs asked on 16 Nov 2018, 07:13 PM

I need to iterate through the grid's rows and determine the boolean value for the checkbox column. This operation occurs when the user clicks on a button outside of the grid.

 

My attempts thus far have not returned 'true' on any rows that have the checkbox checked.

 

1.For x As Integer = 0 To dgvMain.RowCount - 1
2.     
3.    If DirectCast((dgvMain.Rows(x).Cells("colTag")).ColumnInfo, Telerik.WinControls.UI.GridViewCheckBoxColumn).Checked = True Then
4.        _mvTaggedItems &= dgvMain.Rows(x).Cells("colItem").Value & DataBASIC.VM
5.    End If
6.Next

2 Answers, 1 is accepted

Sort by
0
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
answered on 16 Nov 2018, 08:16 PM

After improving my query, I found a good example. Line 06 is what I used, which works. There is probably a more efficient answer.

01.Private Sub BuildRecord()
                             
03.    Try
04.        For x As Integer = 0 To dgvMain.RowCount - 1
05.            Dim bTagged As Boolean = False
06.            Boolean.TryParse(dgvMain.Rows(x).Cells("colTag").Value, bTagged)
07.            If bTagged Then
08.                _mvTaggedItems &= dgvMain.Rows(x).Cells("colItem").Value & DataBASIC.VM
09.            End If
10.        Next
11.        If Strings.Right(_mvTaggedItems, 1) = DataBASIC.VM Then
12.            _mvTaggedItems = Strings.Left(_mvTaggedItems, _mvTaggedItems.Length - 1)
13.        End If
14.    Catch ex As Exception
15.        ShowErrorBox(ex.Message)
16.        _error = True
17.        Exit Sub
18.    End Try
19. 
20.End Sub
0
Dimitar
Telerik team
answered on 19 Nov 2018, 07:22 AM
Hello Bob,

I am glad that you have found a solution to this. Do not hesitate to contact us if you have other questions.
 
Regards,
Dimitar
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Answers by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Dimitar
Telerik team
Share this question
or