problem distinguishing combo null with IPostBackDataHandler

D

David.Morales

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
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top