Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 November 19th, 2003, 05:56 PM
Authorized User
 
Join Date: Oct 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default usercontrol dropdown list... help

I have a question about a usercontrol (ascx) that I've got... I have a dropdownlist on my ascx page and I would like to know how to access that control from the calling aspx pages.. to set a selected value. Does anyone have any insight? I'm kinda stumped. Thanks!

"A spirit with a vision is a dream with a mission"
__________________
\"A spirit with a vision is a dream with a mission\"
 
Old November 19th, 2003, 06:06 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What I have done is to create a public property on the user control class. The accessor for the property looks at the DDL:

Public ReadOnly Property SelectedValue() As String
    Get
        If Not ddlDropDown.SelectedItem Is Nothing Then
            Return ddlDropDown.SelectedItem.Value
        Else
            Return Nothing
        End If
    End Get
End Property

You have to make sure you test it within the accessor otherwise you could get an error if you request it and there is no selected item.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Usercontrol dropdown list databinding forkhead ASP.NET 1.0 and 1.1 Professional 14 February 12th, 2008 02:01 AM
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 12:32 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
HELP WITH DROPDOWN LIST enavas Excel VBA 1 April 6th, 2004 02:08 PM





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