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
Register
Register | FAQ | Members List | Calendar | 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
Reply
 
Thread Tools 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.

Code:
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, MyBase.PreRender
            MyBase.Items.Clear()
            Dim program As New wsPROF_DEVELOPMENT_PROGRAMS.PROF_DEVELOPMENT_PROGRAMSEntity
            Dim entCodes() As wsPROF_DEVELOPMENT_PROGRAMS.PROF_DEVELOPMENT_PROGRAMSEntity
            Dim mangager As New wsPROF_DEVELOPMENT_PROGRAMS.PROF_DEVELOPMENT_PROGRAMSManager

            If GlobalAccessAll Or GlobalAccessInternal Then
                entCodes = mangager.findAll
            Else
                If Not UserID Is Nothing Then
                    If Not TransactionCode Is Nothing Then
                        entCodes = mangager.findByUserIDTransactionCode(UserID, TransactionCode)
                    Else
                        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"
            Else
                MyBase.DataTextField = "PROF_DEV_PROG_DESCR"
            End If
            Try
                If MyBase.SelectedValue = "" Then MyBase.SelectedValue = HttpContext.Current.Request.Item(Me.UniqueID)
            Catch
            End Try

            If Not entCodes Is Nothing Then
                MyBase.DataSource = entCodes
                MyBase.DataBind()
            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
            Get
                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
Reply With Quote
Reply


Thread Tools
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 6th, 2007 11:39 PM
Datagrid Dropdownlist unable to get value ChuckHarkness ASP.NET 1.0 and 1.1 Professional 0 January 23rd, 2007 08: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 12:12 AM



All times are GMT -4. The time now is 09:57 PM.


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