DataGrid Checkbox column CheckedChange event not fired

R

Raymond

Hi all,

I created a custom datagrid control which dynamically
adding checkbox in item template column

In the item template class, it contains a custom event
handler for checkedchange event for checkbox. For some
reason, this event only raised when the checkbox is
selected. When un-checking the checkbox, this event do not
fired.

Please let me know if you've seen this kind of problem
before and give me some suggestion for troublshooting.

thanks in advance!
 
O

Oliver

Hi Raymond,

Could you show us the code that is giving you trouble? Is autopostback set to
true each time you create the control?


Hi all,

I created a custom datagrid control which dynamically
adding checkbox in item template column

In the item template class, it contains a custom event
handler for checkedchange event for checkbox. For some
reason, this event only raised when the checkbox is
selected. When un-checking the checkbox, this event do not
fired.

Please let me know if you've seen this kind of problem
before and give me some suggestion for troublshooting.

thanks in advance!
 
R

Raymond Law

Hi Oliver,

Thanks for your reply. Please see the following section of the code.

Pulbic class MyDataGrid
inherits DataGrid
:
:
:
:
:


Public Class MyItemTemplate
Implements ITemplate

Private colID As String

Public sSelectItem As String
Sub New(ByVal str As String)
colID = str
End Sub


Public Overridable Overloads Sub InstantiateIn(ByVal
container As Control) Implements ITemplate.InstantiateIn
oCheckBox = New CusCheckBox()
oCheckBox.EnableViewState = True
oCheckBox.Enabled = True
oCheckBox.AutoPostBack = True
AddHandler oCheckBox.CheckedChanged, AddressOf
CheckChangedHandler



container.Controls.Add(oCheckBox)
End Sub


Public Sub CheckChangedHandler(ByVal sender As Object, ByVal
e As EventArgs)
Dim oCheckBox2 As CheckBox = CType(sender, CheckBox)
If oCheckBox2.Checked Then
sItems += oCheckBox2.ChkVal
Else
'Removing the items from sItems (a session variable)
End If
End Sub
End Class



Public Class CusCheckBox
Inherits CheckBox
Dim _ChkVal As String

Public Property ChkVal() As String

Get
Return _ChkVal
End Get

Set(ByVal Value As String)
_ChkVal = Value
End Set

End Property
End Class
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top