Template RadioButton

B

Ben Schumacher

I have a template class that allows me to build a radio button into my
gridview control. How do I make the radiobuttons that render in the
gridview control so that only one can be cliked/checked at a time? The
groupname property does nothing for me.

Here is my template class ... FYI, it also handles the implementation of
checkbox and image in the gridview columns. The code for the RadioButton is
the last select case.

Imports Microsoft.VisualBasic

Public Class GridViewTemplate

Implements ITemplate

Dim templateType As DataControlRowType

Dim controlid1 As String

Dim controlenabled As Boolean

Dim controltype As String



Sub New(ByVal type As DataControlRowType, ByVal id1 As String, ByVal onoff
As Boolean, ByVal typeofcontrol As String)

templateType = type

controlid1 = id1

controlenabled = onoff

controltype = typeofcontrol

End Sub



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



Select Case templateType

Case DataControlRowType.DataRow

Select Case controltype

Case "CheckBox"

Dim oCheckBox As New CheckBox

oCheckBox.ID = controlid1

oCheckBox.Enabled = controlenabled

container.Controls.Add(oCheckBox)

oCheckBox = Nothing

Case "Image"

Dim oImage As New Image

oImage.ID = controlid1

oImage.Enabled = controlenabled

container.Controls.Add(oImage)

oImage = Nothing

Case "Radio"

Dim oRadioButton As New RadioButton

oRadioButton.ID = controlid1

oRadioButton.GroupName = "RadioList"

oRadioButton.Enabled = controlenabled

container.Controls.Add(oRadioButton)

oRadioButton = Nothing

End Select

Case Else

' Unexpected Handler ...

End Select



End Sub



End Class
 

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,824
Messages
2,569,755
Members
45,745
Latest member
JohannaLev

Latest Threads

Top