Losing viewstate after inheriting CheckBoxList

E

Earl Teigrob

I am trying to add a property to my CheckBoxList control that renders the
output as text if my own 'ViewOnly' property is set. This works for my
inherited of TextBox and RadioButtonList but I am losing the viewstate
selected items after the first time I render the text only. Is there a way to
save the view state inforation in the control or do I need to write my own
code to maintain view starte. Below is an example of my code. The ViewOnly
property is my own viewstate properties. Thanks for your help.


Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
If ViewOnly Then
Dim Delimiter As String
If Me.RepeatDirection = WebControls.RepeatDirection.Horizontal
Then
Delimiter = ", "
Else
Delimiter = "<br>"
End If
Dim FirstPass As Boolean = True
For Each Item As ListItem In Me.Items
If Item.Selected Then
If Not FirstPass Then
writer.Write(Delimiter)
End If
writer.Write(Item.Text)
FirstPass = False
End If
Next
Else
MyBase.Render(writer)
End If
End Sub
 

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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top