Dropdownlist not displaying list

G

Guest

Hi Everyone,
I had posted a message about the dropdownlist not displaying newly added
items. Just alittle background. I'm working with a masterpage and a
usercontrol(Search control) (VS2005) that contains a few controls and a
dropdownlist. Once the user logs in I have a event that is triggered(Master
page captures event) from another usercontrol(login) and executes
LoadAdminOptions.
So I thought I'd start from scratch and wrote the following code:
Public sub LoadAdminOptions()
cmbOptions.DataSource = CreateDataSource()
cmbOptions.DataTextField = "ItemText"
cmbOptions.DataValueField = "ItemValue"
cmbOptions.DataBind()
End Sub

Function CreateDataSource() As ICollection
Dim dt As New DataTable()
Dim dr As DataRow
Dim lUser as new User

lUser = Session("UserInfo")

dt.Columns.Add(New DataColumn("ItemText", GetType(String )))
dt.Columns.Add(New DataColumn("ItemValue", GetType(Integer )))
dr = dt.NewRow()
dr(0) = "Search by PO ID"
dr(1) = 0
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Search by Field"
dr(1) = 1
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Search between dates"
dr(1) = 2
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Most recent # days"
dr(1) = 3
dt.Rows.Add(dr)
if lUser.Role.RoleName.ToUpper = "ADMIN" then
dr = dt.NewRow()
dr(0) = "Search by UserId"
dr(1) = 4
dt.Rows.Add(dr)
dr = dt.NewRow()
dr(0) = "Awaiting Approval"
dr(1) = 5
dt.Rows.Add(dr)
end if
Dim dv As New DataView(dt)
Return dv
End Function

The problem is that after the code runs, there are NO ITEMS in the list.
Why? This is almost a copy of the code from the online help file. In
searching what was going on I added the following code to the Search control
load event:
if not IsPostBack then
msgbox ("load event")
else
msgbox ("Post Back")
end if
Observations:
Get "load event" when page is first loaded as expected.
When user logs in and event is executed I get "Post Back" my code get
executed and then the I get the "load event". It appears that something is
out of sinc. Anyone have a suggestions how to handle this one. I've gone back
to the event way, cause I was having Major problems getting a reference to
properties or functions from outside the user controls. What do you think?
Thanks for any suggestion.
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top