ITemplate

Discussion in 'ASP .Net' started by Ben Schumacher, Oct 13, 2006.

  1. Ok smart guys and gals ...

    I have a GridView control with a dynamically created checkbox column. The
    checkbox is created using ITemplate interface. In my class that implements
    the ITemplate interface I set the AutoPostBack property of the checkbox to
    True. When the checkbox is clicked, I want to handle the CheckChanged event
    of the checkbox on the webform (.aspx) that contains the GridView control.
    I can easily use the addhandler instruction in the ITemplate interface class
    to handle the CheckChanged event, but how do I bubble the event out to the
    actual .aspx page that contains the gridview control????????????

    I have been googling for hours. It seems no one has any idea how to do
    this. I would be so incredibly grateful for any insight into my problem.

    Ben
     
    Ben Schumacher, Oct 13, 2006
    #1
    1. Advertising

  2. your template should implement IPostBackEventHander. you can raise the
    event.

    -- bruce (sqlwork.com)


    "Ben Schumacher" <> wrote in message
    news:...
    > Ok smart guys and gals ...
    >
    > I have a GridView control with a dynamically created checkbox column. The
    > checkbox is created using ITemplate interface. In my class that
    > implements the ITemplate interface I set the AutoPostBack property of the
    > checkbox to True. When the checkbox is clicked, I want to handle the
    > CheckChanged event of the checkbox on the webform (.aspx) that contains
    > the GridView control. I can easily use the addhandler instruction in the
    > ITemplate interface class to handle the CheckChanged event, but how do I
    > bubble the event out to the actual .aspx page that contains the gridview
    > control????????????
    >
    > I have been googling for hours. It seems no one has any idea how to do
    > this. I would be so incredibly grateful for any insight into my problem.
    >
    > Ben
    >
    >
     
    bruce barker \(sqlwork.com\), Oct 13, 2006
    #2
    1. Advertising

  3. Ben Schumacher

    Teemu Keiski Guest

    Hi,

    I replied to your question with a blog post containing some sample code

    http://aspadvice.com/blogs/joteke/a...mand_2D00_capable-CheckBox-with-GridView.aspx

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke



    "Ben Schumacher" <> wrote in message
    news:...
    > Ok smart guys and gals ...
    >
    > I have a GridView control with a dynamically created checkbox column. The
    > checkbox is created using ITemplate interface. In my class that
    > implements the ITemplate interface I set the AutoPostBack property of the
    > checkbox to True. When the checkbox is clicked, I want to handle the
    > CheckChanged event of the checkbox on the webform (.aspx) that contains
    > the GridView control. I can easily use the addhandler instruction in the
    > ITemplate interface class to handle the CheckChanged event, but how do I
    > bubble the event out to the actual .aspx page that contains the gridview
    > control????????????
    >
    > I have been googling for hours. It seems no one has any idea how to do
    > this. I would be so incredibly grateful for any insight into my problem.
    >
    > Ben
    >
    >
     
    Teemu Keiski, Oct 13, 2006
    #3
  4. Could you elaborate a little?

    Here is what i have so far in my template class ...

    Public Class GridViewTemplate

    Inherits Page

    Implements ITemplate

    Dim templateType As DataControlRowType

    Dim controlid1 As String

    Sub New(ByVal type As DataControlRowType, ByVal id1 As String)

    templateType = type

    controlid1 = id1

    End Sub

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn

    Select Case templateType

    Case DataControlRowType.DataRow

    Dim oCheckBox As New CheckBox

    oCheckBox.ID = controlid1

    oCheckBox.AutoPostBack = True

    container.Controls.Add(oCheckBox)

    oCheckBox = Nothing

    Case Else

    ' Unexpected Handler ...

    End Select

    End Sub

    End Class


    Then in the page is add the checkbox column with ...

    oTemplateField = New TemplateField

    With oTemplateField

    oTemplateField.ItemTemplate = New GridViewTemplate(DataControlRowType.DataRow, "chkSelect")

    End With

    GridControl.Columns.Add(oTemplateField)


    So, how do i raise the event (checkchanged) from within my GridViewTemplate Class and then hadle that even from within the page that contains the GridControl.

    Thanks so much!



    "bruce barker (sqlwork.com)" <> wrote in message news:...
    > your template should implement IPostBackEventHander. you can raise the
    > event.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Ben Schumacher" <> wrote in message
    > news:...
    >> Ok smart guys and gals ...
    >>
    >> I have a GridView control with a dynamically created checkbox column. The
    >> checkbox is created using ITemplate interface. In my class that
    >> implements the ITemplate interface I set the AutoPostBack property of the
    >> checkbox to True. When the checkbox is clicked, I want to handle the
    >> CheckChanged event of the checkbox on the webform (.aspx) that contains
    >> the GridView control. I can easily use the addhandler instruction in the
    >> ITemplate interface class to handle the CheckChanged event, but how do I
    >> bubble the event out to the actual .aspx page that contains the gridview
    >> control????????????
    >>
    >> I have been googling for hours. It seems no one has any idea how to do
    >> this. I would be so incredibly grateful for any insight into my problem.
    >>
    >> Ben
    >>
    >>

    >
    >
     
    Ben Schumacher, Oct 13, 2006
    #4
  5. Is there any chance you could convert your blog example to VB.Net?

    Thanks so much,

    Ben




    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > I replied to your question with a blog post containing some sample code
    >
    > http://aspadvice.com/blogs/joteke/a...mand_2D00_capable-CheckBox-with-GridView.aspx
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    >
    > "Ben Schumacher" <> wrote in message
    > news:...
    >> Ok smart guys and gals ...
    >>
    >> I have a GridView control with a dynamically created checkbox column.
    >> The checkbox is created using ITemplate interface. In my class that
    >> implements the ITemplate interface I set the AutoPostBack property of the
    >> checkbox to True. When the checkbox is clicked, I want to handle the
    >> CheckChanged event of the checkbox on the webform (.aspx) that contains
    >> the GridView control. I can easily use the addhandler instruction in the
    >> ITemplate interface class to handle the CheckChanged event, but how do I
    >> bubble the event out to the actual .aspx page that contains the gridview
    >> control????????????
    >>
    >> I have been googling for hours. It seems no one has any idea how to do
    >> this. I would be so incredibly grateful for any insight into my problem.
    >>
    >> Ben
    >>
    >>

    >
    >
     
    Ben Schumacher, Oct 13, 2006
    #5
  6. Ben Schumacher

    Teemu Keiski Guest

    You can use converter at

    http://authors.aspalliance.com/aldotnet

    It's just that event implementation is bit different in VB.NET (while in
    v2.0 optimized event implementation also exists) so that part you need to
    practise yourself.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    "Ben Schumacher" <> wrote in message
    news:%...
    > Is there any chance you could convert your blog example to VB.Net?
    >
    > Thanks so much,
    >
    > Ben
    >
    >
    >
    >
    > "Teemu Keiski" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> I replied to your question with a blog post containing some sample code
    >>
    >> http://aspadvice.com/blogs/joteke/a...mand_2D00_capable-CheckBox-with-GridView.aspx
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke
    >>
    >>
    >>
    >> "Ben Schumacher" <> wrote in message
    >> news:...
    >>> Ok smart guys and gals ...
    >>>
    >>> I have a GridView control with a dynamically created checkbox column.
    >>> The checkbox is created using ITemplate interface. In my class that
    >>> implements the ITemplate interface I set the AutoPostBack property of
    >>> the checkbox to True. When the checkbox is clicked, I want to handle
    >>> the CheckChanged event of the checkbox on the webform (.aspx) that
    >>> contains the GridView control. I can easily use the addhandler
    >>> instruction in the ITemplate interface class to handle the CheckChanged
    >>> event, but how do I bubble the event out to the actual .aspx page that
    >>> contains the gridview control????????????
    >>>
    >>> I have been googling for hours. It seems no one has any idea how to do
    >>> this. I would be so incredibly grateful for any insight into my
    >>> problem.
    >>>
    >>> Ben
    >>>
    >>>

    >>
    >>

    >
    >
     
    Teemu Keiski, Oct 13, 2006
    #6
    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. cosine... zero
    Replies:
    0
    Views:
    675
    cosine... zero
    Jun 9, 2004
  2. cosine... zero
    Replies:
    0
    Views:
    780
    cosine... zero
    Jun 11, 2004
  3. Andrea Williams

    Datagrid binding to Itemplate Dropdown box

    Andrea Williams, Aug 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,444
    Andrea Williams
    Aug 5, 2004
  4. =?Utf-8?B?QW1pbmU=?=

    Itemplate viewstate

    =?Utf-8?B?QW1pbmU=?=, Jan 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,859
    Karl Seguin
    Jan 17, 2005
  5. Luhar Powell via .NET 247
    Replies:
    0
    Views:
    2,459
    Luhar Powell via .NET 247
    Apr 1, 2005
Loading...

Share This Page