Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 13th, 2007, 09:30 AM
Authorized User
Join Date: Jun 2006
Location: , , .
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 03:20 PM.

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