Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Pre-select a dropdown option

$
0
0
Re: Pre-select a dropdown option
Web Connection 5.0
Re: Pre-select a dropdown option
10/13/2012
07:43:20 PM
3MB169SRK Show this entire thread in new window
Gratar Image based on email address
From:
Stein Goering
To:
Attachments:
None
Well, I thought of that so made sure the assignment was done at the end of OnPreRender() - I even send the value to a log file to verify it.

Maybe I'll embed some debugouts in the the control code and see if I can figure out what's up.


Stein,

The issue most likely is that when you are in Postback mode the SelectedValue is automatically set from the POST data or when you call DataBind and you have a databinding expression attached the value will be set with DataBind() is called. If you set the value before either of these actions the value explicitly set is lost. Typically this means you shouldn't programmatically assign the value before OnLoad() or before you do an explicit DataBind.

The best rule of thumb is to set control values that are also databound or receive POST data as late as possible - this means typically in Event Code or OnPreRender().

+++ Rick ---



I want to preset the default option on a wwWebDropDownList control. I have code in my OnPreRender routine that sets MyList.SelectedValue to the desired option, but I am getting inconsistent results. Sometimes it works - sometimes it comes up with no option preselected. Is there a better way to do this?

--stein




Viewing all articles
Browse latest Browse all 10393

Trending Articles