Public Class DynamicItemTemp late
' ITemplate - When implemented by a class, defines the Control object
' to which child controls and templates belong. These child controls
' are in turn defined within an inline template.
Implements ITemplate
Public Overridable Overloads Sub InstantiateIn(B yVal container As Control)
Implements ITemplate.Insta ntiateIn
' InstantiateIn - When implemented by a class, defines the Control
' object to which child controls and templates belong. These child
' controls are, in turn, defined within an inline template.
'
' Create an instance of a CheckBox object.
Dim oCheckBox As CheckBox = New CheckBox
' When the DataBinding event of the CheckBox fires, call the sub
' BindCheckBox to properly bind.
AddHandler oCheckBox.DataB inding, AddressOf BindCheckBox
'Add the CheckBox to the controls collection.
oCheckBox.Enabl ed = False
container.Contr ols.Add(oCheckB ox)
End Sub
Public Sub BindCheckBox(By Val 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 .NamingContaine r,
DataGridItem)
'Evaluate the data from the Grid item and set the Checked property
' appropriatly
If container.DataI tem("fCurrent") .GetType.ToStri ng = "System.DBN ull" Then
oCheckBox.Check ed = False
Else
oCheckBox.Check ed = CBool(container .DataItem("fCur rent"))
End If
End Sub
"Randy" <te**@temp.co m> wrote in message
news:uM******** ******@TK2MSFTN GP10.phx.gbl...
Hello,
I'm creating a table on the fly that is used by a datagrid. I'm also
creating a tableStyle that is used for the datagrid to make it look like I
want.
I'm using the DataGridBoolCol umn to make one column a CheckBox field. It
shows up fine...as a CheckBox. I looped through the table and stored a
true or false in the checkbox column but it appears to have no effect on the
checkbox column. No matter what I store there (true/false), when I run the
app all the checkboxes are checked/greyed. I thought I could store a true
or false in this column of the table and it would either be checked or
unchecked in the CheckBox...but that doesn't seem to work. Am I going
about it wrong?
Any help would be appreciated...
Thanks