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/12/2012
10:56:52 PM
3MA1D6PGB Show this entire thread in new window
Gratar Image based on email address
From:
Rick Strahl
To:
Attachments:
None
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



Rick Strahl
West Wind Technologies

Making waves on the Web

from Maui, Hawaii
West Wind Web Monitor

Viewing all articles
Browse latest Browse all 10393

Trending Articles