Wrox Programmer Forums
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 7th, 2008, 09:54 AM
Registered User
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

            Dim tf1 As TemplateField = New TemplateField
            tf1.HeaderText = "Account Status"
            tf1.ItemTemplate = New GridViewTemplate(DataControlRowType.DataRow, "isDisabled")

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)
        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
Old April 15th, 2009, 06:14 PM
Registered User
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SPGridView: adding custom TemplateField...

Please take a look at one of my blog posts that details how to go about this:



Similar Threads
Thread Thread Starter Forum Replies Last Post
Paging and Filtering with SPGridView arunduttgp SharePoint Development 1 December 1st, 2008 09:36 PM
How to edit/delete list items through SPGridView meera SharePoint Development 0 December 7th, 2007 11:32 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.