Losing viewstate after inheriting CheckBoxList

Discussion in 'ASP .Net Web Controls' started by Earl Teigrob, Oct 3, 2006.

  1. Earl Teigrob

    Earl Teigrob Guest

    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
     
    Earl Teigrob, Oct 3, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    4
    Views:
    5,030
    Curt_C [MVP]
    Jan 30, 2004
  2. JD
    Replies:
    5
    Views:
    11,683
    NetArchitect
    Aug 8, 2007
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,129
    Patrick.O.Ige
    Jun 19, 2005
  4. dm_dal

    CheckBoxList losing viewstate

    dm_dal, Feb 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    532
    Teemu Keiski
    Feb 18, 2004
  5. Jason C
    Replies:
    4
    Views:
    689
    Morty Abzug
    Jun 26, 2012
Loading...

Share This Page