Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 21st, 2008, 04:14 AM
Authorized User
Join Date: Apr 2008
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default Accessing DropDownList in DetailsView

Hi! I want to set the selected value in a dropdownlist inside detailview using the querystring.
I have:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
 System.EventArgs) Handles Me.Load
        DetailsView1.DropDownList1.SelectedValue = Request("EmployeeID")
    End Sub

but it gives me an error: "DropDownList1 not a member of System.Web.UI.Webcontrols.DetailsView"

How do I access the dropdownlist1?


Old June 21st, 2008, 04:31 AM
Authorized User
Join Date: Apr 2008
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post

I have entered:

Dim DropDownList1 As DropDownList = CType(DetailsView1.FindControl("DropDownList1"), DropDownList)
        DropDownList1.SelectedValue = Request("EmployeeID")

and it works, but is there a simpler way of doing it?

The Following User Says Thank You to firblazer For This Useful Post:
Phil Critchley (March 9th, 2011)
Old June 21st, 2008, 06:48 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Nope; that's how you access controls programmatically when they are nested inside another control like a DetailsView.


Imar Spaanjaars
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot bind from DropDownList to DetailsView kiekar ASP.NET 2.0 Basics 0 February 19th, 2008 09:26 PM
Re-Binding A Dropdownlist In A DetailsView cyber0ne BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 26th, 2007 07:10 PM
Linking two Dropdownlist in DetailsView tna55 ASP.NET 2.0 Basics 0 February 12th, 2007 10:29 AM
DropDownList in side the DetailsView ndc550 ASP.NET 2.0 Basics 0 October 19th, 2006 05:10 PM
dropdownlist value into detailsview: how? hertendreef ASP.NET 2.0 Professional 0 June 26th, 2006 01:54 AM

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