SPGridView
I'm trying to dynamically create a GridView with a checkboxes that fires when click however, my onclick event is not being triggered.
Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
oGrid.ID = "grid"
oGrid.AutoGenerateColumns = False
oGrid.Columns.Clear()
Dim tf1 As TemplateField = New TemplateField
tf1.HeaderText = "Account Status"
tf1.ItemTemplate = New GridViewTemplate(DataControlRowType.DataRow, "isDisabled")
oGrid.Columns.Add(tf1)
....
End Sub
Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
Select Case templateType
Case DataControlRowType.DataRow
Dim cb As CheckBox = New CheckBox
cb.ID = "cbStatus"
cb.AutoPostBack = True
cb.EnableViewState = True
AddHandler cb.DataBinding, AddressOf BindCheckBox
AddHandler cb.CheckedChanged, New EventHandler(AddressOf CheckedChanged)
container.Controls.Add(cb)
End Select
End Sub
Public Sub CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim data As New AdminParentAcctData(GetConnectionString())
Dim StudentId As String = String.Empty
Dim stdnt As New Student(GetConnectionString())
Dim cb As CheckBox = CType(sender, CheckBox)
Dim row As GridViewRow = CType(cb.NamingContainer, GridViewRow)
If cb.Checked = True Then
Dim username As String = CType(row.Cells(2).Text, String)
data.updatePermissions(username, Id)
End If
End Sub
|