problem distinguishing combo null with IPostBackDataHandler

Discussion in 'ASP .Net Building Controls' started by David.Morales, Feb 28, 2006.

  1. I have built a webcontrol that outputs a select/option html element amongst
    other html. I had implemented IPostBackDataHandler differently and not had
    the registerrequirespostback, but if a user selected an empty value in the
    dropdown, no LoadPostData took place and the value was not saved. Now I am
    using:

    public bool LoadPostData(string postDataKey, NameValueCollection
    postCollection)
    {
    if (EditMode){
    string oldSelectedValue = SelectedValue;
    if (postCollection.GetValues(postDataKey) == null) SelectedValue =
    string.Empty;
    else SelectedValue = postCollection.GetValues(postDataKey)[0]; //I have
    overridden load/saveviewstate to store list in [1] which works fine
    return oldSelectedValue != SelectedValue;
    }
    return false;
    }

    and added

    if (Page != null) {Page.RegisterRequiresPostBack(this);}

    to OnInit

    (Edit mode is a property that changes the render from outputting a select or
    just text.)

    This now updates fine regardless of whether the selectedentry is a proper
    value or an empty value. The problem is that now all values are lost when I
    move from tab to tab (asp:panels) on my page. All textboxes maintain their
    values though, and if I set editmode to false, the text is remembered for
    the combos (though in edit mode, just a label is rendered).

    Any ideas/pointers etc would be appreciated.

    Thanks
     
    David.Morales, Feb 28, 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. Showjumper

    Re: Help w/ IPostBackDataHandler

    Showjumper, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,642
    Showjumper
    Jun 24, 2003
  2. Replies:
    5
    Views:
    26,707
    Mike Schilling
    Mar 29, 2006
  3. Piotr Nowak

    IPostBackDataHandler problem

    Piotr Nowak, Sep 5, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    851
    Piotr Nowak
    Sep 6, 2007
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    595
    Bob Barrows [MVP]
    Nov 16, 2005
  5. SM
    Replies:
    2
    Views:
    373
Loading...

Share This Page