ListControl: SelectedIndexChanged event raised without implementing IPostBackDataHandler?

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default ListControl: SelectedIndexChanged event raised without implementing IPostBackDataHandler?

    Hi,

    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
    Nothing
    If selected <> item.Selected Then
    changed = True
    End If
    item.Selected = selected
    Next

    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?
    Thanks

    Henri



    Henri Guest

  2. Similar Questions and Discussions

    1. Custom ListControl OnFocus Event not working
      Hey All, I have created a custom control that initially shows a textbox. After the user has typed something in the TextBox a DropDownListbox is...
    2. DataList's EditCommand event not being raised
      I am attempting to raise the EditCommand event of a DataList when a Button in the ItemTemplate is clicked. Here is the HTML used for the...
    3. ItemDataBound Event - How to access the previous record when this event is raised in DataGrid?
      ItemDataBound Event - How to access the previous record when this event is raised in DataGrid? During "ItemDataBound Event", I would like...
    4. Implementing IPostBackDataHandler in a custom web control with VB.NET
      I have created a custom class with Visual Basic that inherits from the drop down list web control. In order to update the value properly, I have...
    5. SelectedIndexChanged event in DropDownList
      Hi. Why cannot I capture the SelectedIndexChanged event from a DropDownList when the viewstate is set to false (it must be set to false because of...
  3. #2

    Default Re: ListControl: SelectedIndexChanged event raised without implementing IPostBackDataHandler?

    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
    System.Web.UI.IPostBackDataHandler.RaisePostDataCh angedEvent()
    Implements IPostBackDataHandler.RaisePostDataChangedEvent
    ' Do whatever you want to.
    End Sub




    Cheers,
    Gaurav Vaish
    [url]http://mastergaurav.org[/url]
    [url]http://mastergaurav.blogspot.com[/url]
    ------------------------

    MasterGaurav Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139