Cant set drop down list selected value in page load

Posted by Ben on Stack Overflow See other posts from Stack Overflow or by Ben
Published on 2010-06-03T04:31:18Z Indexed on 2010/06/03 4:34 UTC
Read the original article Hit count: 281

Filed under:
|

Hi,

I'm trying to set the selected value of a ddl during page load ie. before databind.

This causes "selected value does not exist" errors. So I force a databind, and add a new element if it does not exist in the data source.

However it looks like when the databind is performed later in the page lifecycle that my added element(s) are removed/overwritten.

Am I setting the values in the wrong part of the life cycle? what I'm doing seems rather hackish and I think im going about this the wrong way... is there a better way to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET