Dropdownlist not displaying list

Discussion in 'ASP .Net' started by =?Utf-8?B?TWljaGFlbA==?=, Apr 28, 2006.

  1. 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
     
    =?Utf-8?B?TWljaGFlbA==?=, Apr 28, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim French
    Replies:
    0
    Views:
    338
    Jim French
    Jul 21, 2003
  2. tshad
    Replies:
    1
    Views:
    500
    societopia.net
    Jun 9, 2005
  3. Replies:
    1
    Views:
    500
  4. donet programmer
    Replies:
    0
    Views:
    807
    donet programmer
    Oct 25, 2007
  5. JR

    dropdownlist not displaying all items?

    JR, Aug 19, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    167
Loading...

Share This Page