Hi
I simply want to set the selected item of a dropdownlist on page_load ...spent over 2 hrs trying to get this to work, but getting no response
The idea is, anytime the page is loaded I need to set the dropdownlist to have a specific selected item ...currently I'm just trying to get it to accept the third item in the list as default (value: 000003) ...but it keeps going to the first item (value: 000001)
Here's my page load ...can someone show me WHERE to set the selected item for my dropdown list ...and HOW :-):
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Try
If Not IsPostBack Then
BindData() 'fills datagrid with qa filter
Fill_Combo() 'fills all the drop downs
End If
Catch ex As Exception
Msg.Text = ex.Message
Finally
End Try
End Sub
BindData() fills a datagrid I have and fill_combo() fills the dropdownlists
The dropdownlist I want to set the selected value for is called: ddl_principle_choice
I've tried adding this after Fill_Combo():
ddl_principle_choice.Selec
tedItem.Va
lue = "000003"
...but can't get it to work ...I've tried adding it on the outside of the If ...but still no luck
Can anyone help me? This must be so simple but is driving me crazy
Thanks
Mark
PS ...if you need to see the code for fill_combo, I've included it below:
************
Private Sub Fill_Combo()
Dim Ndx As Integer
Dim Col As New Collection
Dim lstItem As ListItem
Try
ddl_principle_choice.Items
.Clear()
Dim Obj1 As New objClass.cls_Accred_Princi
ple
Obj1.org_code = OrgCode
Obj1.Clvl = dbLevel
Col = Obj1.ListAllItems()
For Ndx = 1 To Col.Count
lstItem = New ListItem
Dim Obj1a As New objClass.cls_Accred_Qualit
y_Area
Obj1a.org_code = OrgCode
Obj1a.Clvl = dbLevel
Obj1a.area_id = Col(Ndx).quality_area
Obj1a.LoadItem()
lstItem.Text = Obj1a.area_abbr & " - " & Col(Ndx).principle_name & ": " & Col(Ndx).principle_descrip
tion
lstItem.Value = Col(Ndx).principle_id 'Eg. 000003
ddl_principle.Items.Add(ls
tItem)
Next Ndx
Obj1 = Nothing
'clear objects for GC
Col = Nothing
Catch ex As Exception
Msg.Text = ex.Message
Finally
End Try
End Sub
***************