Access Datagrid from member sub / function

Code sample to access Datagrid values from another member sub / function apart from Datagrid events.

    Private Sub temp

Dim dgi As DataGridItem
‘dgdFormTypes is the id for Datagrid.   

For
Each dgi In dgdFormTypes.Items 
       
Code = dgi.Cells(4).Text
        Name = dgi.Cells(5).Text        ‘If Datagrid has some Control in any column then
        Dim ctlInt As Control = dgi.Cells(1).FindControl(“chkInt”)        ‘ Get the value of that Control, in this case its a Checkbox
        CType(ctlInt, CheckBox).Checked 
    Next
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.