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