N
Niclas Lindblom
Hi,
I have a datagrid that contains a checkbox template column. I have followed
the sample in Q306227, but I have a problem evaluating the content of the
datagrid columns to decide a value for the checkboxes check property.
According to the sample I should use this statement in the BindCheckbox
event to evaluate a column:
Public Sub BindCheckBox(ByVal sender As Object, ByVal e As EventArgs)
'Create a new instance of a CheckBox.
Dim oCheckBox As CheckBox = CType(sender, CheckBox)
Dim container As DataGridItem = CType(oCheckBox.NamingContainer,
DataGridItem)
'Evaluate the data from the Grid item and set the Checked property
' appropriatly
If container.DataItem("contract").GetType.ToString = "System.DBNull"
Then
oCheckBox.Checked = False
Else
oCheckBox.Checked = CBool(container.DataItem("contract"))
End If
End Sub
The problem here is that my project is configured to use "Option Strict" and
does therefore not allow the statement
If container.DataItem("contract").GetType.ToString = "System.DBNull" Then
I tried to use Container.cells(2).text instead, but this only returns a
empty string in all rows.
Any suggestions on how to to do this ?
Regards
Niclas
I have a datagrid that contains a checkbox template column. I have followed
the sample in Q306227, but I have a problem evaluating the content of the
datagrid columns to decide a value for the checkboxes check property.
According to the sample I should use this statement in the BindCheckbox
event to evaluate a column:
Public Sub BindCheckBox(ByVal sender As Object, ByVal e As EventArgs)
'Create a new instance of a CheckBox.
Dim oCheckBox As CheckBox = CType(sender, CheckBox)
Dim container As DataGridItem = CType(oCheckBox.NamingContainer,
DataGridItem)
'Evaluate the data from the Grid item and set the Checked property
' appropriatly
If container.DataItem("contract").GetType.ToString = "System.DBNull"
Then
oCheckBox.Checked = False
Else
oCheckBox.Checked = CBool(container.DataItem("contract"))
End If
End Sub
The problem here is that my project is configured to use "Option Strict" and
does therefore not allow the statement
If container.DataItem("contract").GetType.ToString = "System.DBNull" Then
I tried to use Container.cells(2).text instead, but this only returns a
empty string in all rows.
Any suggestions on how to to do this ?
Regards
Niclas