p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Assigning a SelectedValue in a DropDownList (http://p2p.wrox.com/showthread.php?t=40317)

rit01 March 24th, 2006 06:42 AM

Assigning a SelectedValue in a DropDownList
 
Hi all

How would I assign a SelectedValue to a DropDownList control within the Page_Load event?... I have tried the following line but doesn't seem to like it..

Code:

Dim DDL As DropDownList = FormView1.FindControl("DDLProfile")
DDL.SelectedValue = "1"

The dropdownlist is static as in it isn't bound to a DB table.

The error I get from this is the following:

Quote:

quote:Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Many thanks

Rit

jbenson001 March 24th, 2006 03:15 PM

I don't know why you are getting that error, you need to check your code. Also, make sure you value is actually "1" in the ddl


rit01 March 24th, 2006 06:30 PM

Sorry all... blurry eyed.. need to get away from the PC more I think.

It was actually referring to another piece of code.. anyway all fixed.

Ta

Rit

jbenson001 March 25th, 2006 01:12 AM

ok..Well, glad is all is fixed... :)

Jim



All times are GMT -4. The time now is 12:01 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.