You may be accessing the value before the viewstate has been loaded and
control values updated from the form post. Try looking at the value in
PreRender to check if this is the case.
Regards,
mr fox.
"Sam C via .NET 247" wrote:
> Hi,
>
> I have a really irritating problem with an ASP.NET page that I'm trying to get to work. It includes a DropDownList which I populate with ListItems in the Page_Load in cases where IsPostBack = False.
>
> When using any of the several methods to get the selected item in the DDL it always returns the first one in the DropDownList despite the fact that one of the other items may actually be selected. I've tried
>
> I've now made the page just write out the value of the DDL.SelectedItem as a debugging tool. The odd thing is that, if I resubmit the form it then starts to get the right value but, of course, it's the first time the form is submitted that I really need it to be right.
>
> I'd appreciate any help and can post any code that is needed. I see from other forum posts that some others have had the same problem but the only advice they get is to make sure the IsPostBack is used in an IF statement in Page_Load which I am doing.
>
> Thanks,
>
> Sam
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>m96oaRmQAkGDbrjEmcot9g==</Id>
>