Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 April 13th, 2007, 09:30 AM
Authorized User
Join Date: Jun 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jlrolin Send a message via MSN to jlrolin
Default Unable to set SelectedValue on DropDownList

Here's my scenario.

I have a custom control that inherits DropDownList. This was the old functionality of an ASP.net 1.1 control that a company created before I came on.

The control had a DefaultValue() function that I am unsure of what it did exactly, but I'm trying to mimic it. Basically, it made a property for the dropdownlist.

DropDownList1.DefaultValue = obj.COUNTY_DDL

This would assign a string value to DefaultValue, I'm assuming it set the Selected Value. For the life of me, I CANNOT SET THE SELECTEDVALUE ever! Here's the code. I believe it has something to do with where I'm trying to set this. Point me in the right direction if you can.

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, MyBase.PreRender

            If GlobalAccessAll Or GlobalAccessInternal Then
                entCodes = mangager.findAll
                If Not UserID Is Nothing Then
                    If Not TransactionCode Is Nothing Then
                        entCodes = mangager.findByUserIDTransactionCode(UserID, TransactionCode)
                        entCodes = mangager.findByUserID(UserID)
                    End If
                End If
            End If

            'MyBase.Entities = entCodes

            MyBase.DataValueField = "PROF_DEVELOPMENT_PROGRAMS_ID"
            If DisplayID Then
                MyBase.DataTextField = "PROF_DEVELOPMENT_PROGRAMS_ID"
                MyBase.DataTextField = "PROF_DEV_PROG_DESCR"
            End If
                If MyBase.SelectedValue = "" Then MyBase.SelectedValue = HttpContext.Current.Request.Item(Me.UniqueID)
            End Try

            If Not entCodes Is Nothing Then
                MyBase.DataSource = entCodes
            End If

            If m_none Then
                MyBase.Items.Insert(0, "*NONE*")
                MyBase.Items(0).Value = ""
            End If

        End Sub

I have a bunch of properties, all which work except:

        Public Property DefaultValue() As String
                Return MyBase.SelectedValue
            End Get
            Set(ByVal Value As String)
                MyBase.SelectedValue = Value
            End Set
        End Property
ASP.NET 1.1 Developer
VB.NET Developer
ASP.NET 1.1/2.0 Developer
VB.NET Developer

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with DropDownList SelectedValue putputty ASP.NET 2.0 Basics 4 June 27th, 2007 11:44 AM
DropDownList.SelectedValue weirdness Aaron Edwards ASP.NET 2.0 Basics 5 March 7th, 2007 12:39 AM
Datagrid Dropdownlist unable to get value ChuckHarkness ASP.NET 1.0 and 1.1 Professional 0 January 23rd, 2007 09:32 AM
Set cbo.selectedvalue using Value problem persists Ron Howerton Visual Basic 2005 Basics 0 July 12th, 2006 11:52 AM
Assigning a SelectedValue in a DropDownList rit01 ASP.NET 2.0 Professional 3 March 25th, 2006 01:12 AM

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