ITemplate

B

Ben Schumacher

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
 
B

bruce barker \(sqlwork.com\)

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

-- bruce (sqlwork.com)
 
B

Ben Schumacher

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!
 
B

Ben Schumacher

Is there any chance you could convert your blog example to VB.Net?

Thanks so much,

Ben
 

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,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top