Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Template RadioButton

Reply
Thread Tools

Template RadioButton

 
 
Ben Schumacher
Guest
Posts: n/a
 
      06-02-2006
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


 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      06-02-2006
http://www.codeproject.com/aspnet/Ho...p_RButtons.asp
http://www.codeproject.com/aspnet/groupradiobuttons.asp

You'll need to convert code above to a programmatic GridView with
RadioButton grouping yourself.
Good Luck.
Andy

Ben Schumacher wrote:
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Dynamically Inserted Template with RadioButton gauty ASP .Net Web Controls 1 04-29-2010 10:27 AM
Radiobutton item template =?Utf-8?B?QmFkaXM=?= ASP .Net 3 12-05-2006 12:40 PM
Radiobutton Template column in Datagrid Anil ASP .Net Web Controls 1 09-17-2003 10:30 AM
Re: A Newbie Question about template template template tom_usenet C++ 0 07-24-2003 12:06 PM
Re: A Newbie Question about template template template Chris Theis C++ 2 07-24-2003 09:42 AM



Advertisments