ListControl: SelectedIndexChanged event raised without implementing IPostBackDataHandler?

Discussion in 'ASP .Net Building Controls' started by Henri, May 19, 2005.

  1. Henri

    Henri Guest


    I'm designing a control that inherits ListControl
    I was surprised to see that SelectedIndexChanged is part of ListControl. So
    why doesn't it implement IPostBackDataHandler?
    I added this to my control:

    Function LoadPostData(postDataKey As String, postCollection As
    NameValueCollection) As Boolean Implements IPostBackDataHandler.LoadPostData

    Dim changed As Boolean
    For i As Integer = 0 To Items.Count - 1
    Dim item As ListItem = Items(i)
    Dim selected As Boolean
    selected = Not postCollection(UniqueID & "_" & item.Value) Is
    If selected <> item.Selected Then
    changed = True
    End If
    item.Selected = selected

    Return changed

    End Function

    but now I can't raise any SelectedIndexChanged from
    RaisePostDataChangedEvent() as this event belongs to the base class
    ListControl and I get a compile error if I try to.

    I really don't understand the logic of ListControl: must I check if values
    have changed between posts myself or does ListControl do it by itself? So if
    ListControl do it itself, what is a class that inherits ListControl supposed
    to do when implementing IPostBackDataHandler?

    Can you help me?

    Henri, May 19, 2005
    1. Advertisements

  2. Henri

    MasterGaurav Guest

    ListControl is abstract class. It's subclasses - CheckBoxList, DDL,
    ListBox, RadioButtonList -- all implement IPostBackDataHandler.

    btw, make an explicit implementation of the methods. For example:

    Private Sub
    Implements IPostBackDataHandler.RaisePostDataChangedEvent
    ' Do whatever you want to.
    End Sub

    Gaurav Vaish
    MasterGaurav, May 20, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.