Drop-down lists populated twice due to page_load being processed t

Discussion in 'ASP .Net Web Controls' started by smccreadie, Oct 27, 2006.

  1. smccreadie

    smccreadie Guest

    I've got some drop-downs on a page that are being loaded as such:

    Sub load_existing_accounts()
    'loads existing protocol accounts into the grid if any
    Dim db As Database = DatabaseFactory.CreateDatabase()
    Dim ds As DataSet =
    db.ExecuteDataSet("billing_protocol_accounts_get_current",
    Request.QueryString("protocol_id"))

    gv_accounts_in_protocol.DataSource = ds.Tables(0)
    gv_accounts_in_protocol.DataBind()

    'load the drop-downs below as well -- for some reason these are
    coming up duplicated in each drop down??????
    ddl_startup_account.DataSource = ds.Tables(0)
    ddl_startup_account.DataTextField = "account_name"
    ddl_startup_account.DataValueField = "billing_account_id"
    ddl_startup_account.DataBind()

    ddl_inventory_account.DataSource = ds.Tables(0)
    ddl_inventory_account.DataTextField = "account_name"
    ddl_inventory_account.DataValueField = "billing_account_id"
    ddl_inventory_account.DataBind()

    ddl_randomization_account.DataSource = ds.Tables(0)
    ddl_randomization_account.DataTextField = "account_name"
    ddl_randomization_account.DataValueField = "billing_account_id"
    ddl_randomization_account.DataBind()

    ddl_storage_account.DataSource = ds.Tables(0)
    ddl_storage_account.DataTextField = "account_name"
    ddl_storage_account.DataValueField = "billing_account_id"
    ddl_storage_account.DataBind()

    ddl_dispensing_fee_account.DataSource = ds.Tables(0)
    ddl_dispensing_fee_account.DataTextField = "account_name"
    ddl_dispensing_fee_account.DataValueField = "billing_account_id"
    ddl_dispensing_fee_account.DataBind()

    End Sub

    They all contain the same data from the datasource plus have a
    statically-defined item with the appenddatabounditems = True.

    For some reason, this page is calling page_load twice which results in the
    drop-downs containing a duplicate of the datasource items. The gridview
    which is also filled, only has a single copy as expected.

    I'm not sure where is is coming from. The page_load sub is clearly marked as

    If Not IsPostBack Then
    'load existing accounts
    load_existing_accounts()
    End If

    --
    Scott McCreadie
     
    smccreadie, Oct 27, 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. VB Programmer
    Replies:
    0
    Views:
    544
    VB Programmer
    Dec 17, 2003
  2. bminder
    Replies:
    1
    Views:
    2,214
    nfedin
    Feb 23, 2004
  3. SirPoonga
    Replies:
    2
    Views:
    825
    Ben Strackany
    Jan 7, 2005
  4. Accelerator
    Replies:
    1
    Views:
    488
    Ray Booysen
    Mar 20, 2006
  5. weiwei
    Replies:
    0
    Views:
    1,077
    weiwei
    Jan 5, 2007
Loading...

Share This Page