DataGrid Checkbox column CheckedChange event not fired

Discussion in 'ASP .Net Web Controls' started by Raymond, Oct 19, 2003.

  1. Raymond

    Raymond Guest

    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!
     
    Raymond, Oct 19, 2003
    #1
    1. Advertising

  2. Raymond

    Oliver Guest

    Hi Raymond,

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


    "Raymond" <> wrote in message
    news:05ee01c3965d$5c2f6240$...
    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!
     
    Oliver, Oct 22, 2003
    #2
    1. Advertising

  3. Raymond

    Raymond Law Guest

    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







    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Raymond Law, Oct 24, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=

    RE: what event is fired?-template column

    =?Utf-8?B?U2hhaWxlc2ggSmFubnU=?=, Aug 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    561
    Scott Allen
    Aug 26, 2004
  2. =?Utf-8?B?ZGF2aWQ=?=

    determine CheckBox's checkedChange status dynamically?

    =?Utf-8?B?ZGF2aWQ=?=, May 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,352
    =?Utf-8?B?ZGF2aWQ=?=
    May 4, 2005
  3. Gregory Rampton

    Convert an MS Access Yes/No column to a checkbox column in C# datagrid

    Gregory Rampton, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    212
    Gregory Rampton
    Aug 6, 2003
  4. Kelly

    radio button CheckedChange event

    Kelly, Nov 12, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    247
    Kelly
    Nov 12, 2004
  5. biru
    Replies:
    2
    Views:
    233
Loading...

Share This Page