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.   

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

Leave a Reply

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

%d bloggers like this: