Loading a listbox from a Dropdownlist

Discussion in 'ASP .Net' started by gv, Jan 27, 2005.

  1. gv

    gv Guest

    Ok,

    Hi all, new to asp.net. Simple question

    with web forms

    I have a Dropdownlist and a listbox, I want to click on and item in the
    dropdownlist and show items in listbox. that simple

    I have this: I have two items in Dropdownlist. The Reportlist doesn't show
    the items ?

    I tried to set the Autopostback to true. This does work but, the page
    flickers

    Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    Databaselist.SelectedIndexChanged
    If Databaselist.SelectedValue = "Test1" Then

    ReportList.Items.Clear()
    ReportList.Items.Add("Test1Totals by Date Range")
    ReportList.Items.Add("Test1Totals by name and Date Range")

    ElseIf Databaselist.SelectedValue = "Test2" Then

    ReportList.Items.Clear()
    ReportList.Items.Add("Test2Totals by Date Range")
    ReportList.Items.Add("Test2 Totals by name and Date Range")

    End If
    End Sub
    gv, Jan 27, 2005
    #1
    1. Advertising

  2. gv

    Curt_C [MVP] Guest

    are you clearing them/setting them in the page_load? You may be blanking
    them out each time.
    look at the IsPostBack() to differentiate

    --
    Curt Christianson
    Site & Scripts: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "gv" <> wrote in message
    news:%238r%...
    > Ok,
    >
    > Hi all, new to asp.net. Simple question
    >
    > with web forms
    >
    > I have a Dropdownlist and a listbox, I want to click on and item in the
    > dropdownlist and show items in listbox. that simple
    >
    > I have this: I have two items in Dropdownlist. The Reportlist doesn't show
    > the items ?
    >
    > I tried to set the Autopostback to true. This does work but, the page
    > flickers
    >
    > Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    > System.Object, ByVal e As System.EventArgs) Handles
    > Databaselist.SelectedIndexChanged
    > If Databaselist.SelectedValue = "Test1" Then
    >
    > ReportList.Items.Clear()
    > ReportList.Items.Add("Test1Totals by Date Range")
    > ReportList.Items.Add("Test1Totals by name and Date Range")
    >
    > ElseIf Databaselist.SelectedValue = "Test2" Then
    >
    > ReportList.Items.Clear()
    > ReportList.Items.Add("Test2Totals by Date Range")
    > ReportList.Items.Add("Test2 Totals by name and Date Range")
    >
    > End If
    > End Sub
    >
    Curt_C [MVP], Jan 27, 2005
    #2
    1. Advertising

  3. gv

    gv Guest

    Thanks for your help, I'm only clearing the listbox before I load the new
    values based on what is selected in the dropdownlist.
    The values load fine when the page first opens. Not when the
    controls SelectedIndexChanged event fires.

    GV




    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:...
    > are you clearing them/setting them in the page_load? You may be blanking
    > them out each time.
    > look at the IsPostBack() to differentiate
    >
    > --
    > Curt Christianson
    > Site & Scripts: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "gv" <> wrote in message
    > news:%238r%...
    >> Ok,
    >>
    >> Hi all, new to asp.net. Simple question
    >>
    >> with web forms
    >>
    >> I have a Dropdownlist and a listbox, I want to click on and item in the
    >> dropdownlist and show items in listbox. that simple
    >>
    >> I have this: I have two items in Dropdownlist. The Reportlist doesn't
    >> show the items ?
    >>
    >> I tried to set the Autopostback to true. This does work but, the page
    >> flickers
    >>
    >> Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    >> System.Object, ByVal e As System.EventArgs) Handles
    >> Databaselist.SelectedIndexChanged
    >> If Databaselist.SelectedValue = "Test1" Then
    >>
    >> ReportList.Items.Clear()
    >> ReportList.Items.Add("Test1Totals by Date Range")
    >> ReportList.Items.Add("Test1Totals by name and Date Range")
    >>
    >> ElseIf Databaselist.SelectedValue = "Test2" Then
    >>
    >> ReportList.Items.Clear()
    >> ReportList.Items.Add("Test2Totals by Date Range")
    >> ReportList.Items.Add("Test2 Totals by name and Date Range")
    >>
    >> End If
    >> End Sub
    >>

    >
    >
    gv, Jan 27, 2005
    #3
  4. gv

    Karl Seguin Guest

    Gv:
    It works fine for me. Are you sure you have the AutoPostBack=true for the
    dropdownlist?

    karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "gv" <> wrote in message
    news:%238r%...
    > Ok,
    >
    > Hi all, new to asp.net. Simple question
    >
    > with web forms
    >
    > I have a Dropdownlist and a listbox, I want to click on and item in the
    > dropdownlist and show items in listbox. that simple
    >
    > I have this: I have two items in Dropdownlist. The Reportlist doesn't show
    > the items ?
    >
    > I tried to set the Autopostback to true. This does work but, the page
    > flickers
    >
    > Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    > System.Object, ByVal e As System.EventArgs) Handles
    > Databaselist.SelectedIndexChanged
    > If Databaselist.SelectedValue = "Test1" Then
    >
    > ReportList.Items.Clear()
    > ReportList.Items.Add("Test1Totals by Date Range")
    > ReportList.Items.Add("Test1Totals by name and Date Range")
    >
    > ElseIf Databaselist.SelectedValue = "Test2" Then
    >
    > ReportList.Items.Clear()
    > ReportList.Items.Add("Test2Totals by Date Range")
    > ReportList.Items.Add("Test2 Totals by name and Date Range")
    >
    > End If
    > End Sub
    >
    >
    Karl Seguin, Jan 27, 2005
    #4
  5. gv

    gv Guest

    If I do that, it works fine like I said but, flickers?

    I don't want it to flicker when I do this.

    thanks
    gv


    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:...
    > Gv:
    > It works fine for me. Are you sure you have the AutoPostBack=true for the
    > dropdownlist?
    >
    > karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "gv" <> wrote in message
    > news:%238r%...
    >> Ok,
    >>
    >> Hi all, new to asp.net. Simple question
    >>
    >> with web forms
    >>
    >> I have a Dropdownlist and a listbox, I want to click on and item in the
    >> dropdownlist and show items in listbox. that simple
    >>
    >> I have this: I have two items in Dropdownlist. The Reportlist doesn't
    >> show
    >> the items ?
    >>
    >> I tried to set the Autopostback to true. This does work but, the page
    >> flickers
    >>
    >> Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    >> System.Object, ByVal e As System.EventArgs) Handles
    >> Databaselist.SelectedIndexChanged
    >> If Databaselist.SelectedValue = "Test1" Then
    >>
    >> ReportList.Items.Clear()
    >> ReportList.Items.Add("Test1Totals by Date Range")
    >> ReportList.Items.Add("Test1Totals by name and Date Range")
    >>
    >> ElseIf Databaselist.SelectedValue = "Test2" Then
    >>
    >> ReportList.Items.Clear()
    >> ReportList.Items.Add("Test2Totals by Date Range")
    >> ReportList.Items.Add("Test2 Totals by name and Date Range")
    >>
    >> End If
    >> End Sub
    >>
    >>

    >
    >
    gv, Jan 27, 2005
    #5
  6. gv

    Karl Seguin Guest

    Geez..so much for reading through everything....i didn't catch that at all.

    One solution is to do everything on the client-side...which has its up and
    down side.

    Another one is to turn on SmartNavigation which only works in IE and some
    people have a lot of problems with it. Try putting SmartNaviation=true in
    the <%@ Page directive...
    You should check out:
    http://weblogs.asp.net/ksamaschke/archive/2003/04/27/6085.aspx or just do a
    google search for SmartNavigation

    Other that that, it's the nature of doing web programming...

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "gv" <> wrote in message
    news:...
    > If I do that, it works fine like I said but, flickers?
    >
    > I don't want it to flicker when I do this.
    >
    > thanks
    > gv
    >
    >
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > wrote in message news:...
    > > Gv:
    > > It works fine for me. Are you sure you have the AutoPostBack=true for

    the
    > > dropdownlist?
    > >
    > > karl
    > >
    > > --
    > > MY ASP.Net tutorials
    > > http://www.openmymind.net/
    > >
    > >
    > > "gv" <> wrote in message
    > > news:%238r%...
    > >> Ok,
    > >>
    > >> Hi all, new to asp.net. Simple question
    > >>
    > >> with web forms
    > >>
    > >> I have a Dropdownlist and a listbox, I want to click on and item in the
    > >> dropdownlist and show items in listbox. that simple
    > >>
    > >> I have this: I have two items in Dropdownlist. The Reportlist doesn't
    > >> show
    > >> the items ?
    > >>
    > >> I tried to set the Autopostback to true. This does work but, the page
    > >> flickers
    > >>
    > >> Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    > >> System.Object, ByVal e As System.EventArgs) Handles
    > >> Databaselist.SelectedIndexChanged
    > >> If Databaselist.SelectedValue = "Test1" Then
    > >>
    > >> ReportList.Items.Clear()
    > >> ReportList.Items.Add("Test1Totals by Date Range")
    > >> ReportList.Items.Add("Test1Totals by name and Date Range")
    > >>
    > >> ElseIf Databaselist.SelectedValue = "Test2" Then
    > >>
    > >> ReportList.Items.Clear()
    > >> ReportList.Items.Add("Test2Totals by Date Range")
    > >> ReportList.Items.Add("Test2 Totals by name and Date Range")
    > >>
    > >> End If
    > >> End Sub
    > >>
    > >>

    > >
    > >

    >
    >
    Karl Seguin, Jan 27, 2005
    #6
  7. gv

    Curt_C [MVP] Guest

    you cant avoid the flicker. That is the page making a round trip to the
    server, its unavoidable unless you do it all with clientside code

    --
    Curt Christianson
    Site & Scripts: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "gv" <> wrote in message
    news:...
    > If I do that, it works fine like I said but, flickers?
    >
    > I don't want it to flicker when I do this.
    >
    > thanks
    > gv
    >
    >
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > wrote in message news:...
    >> Gv:
    >> It works fine for me. Are you sure you have the AutoPostBack=true for
    >> the
    >> dropdownlist?
    >>
    >> karl
    >>
    >> --
    >> MY ASP.Net tutorials
    >> http://www.openmymind.net/
    >>
    >>
    >> "gv" <> wrote in message
    >> news:%238r%...
    >>> Ok,
    >>>
    >>> Hi all, new to asp.net. Simple question
    >>>
    >>> with web forms
    >>>
    >>> I have a Dropdownlist and a listbox, I want to click on and item in the
    >>> dropdownlist and show items in listbox. that simple
    >>>
    >>> I have this: I have two items in Dropdownlist. The Reportlist doesn't
    >>> show
    >>> the items ?
    >>>
    >>> I tried to set the Autopostback to true. This does work but, the page
    >>> flickers
    >>>
    >>> Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    >>> System.Object, ByVal e As System.EventArgs) Handles
    >>> Databaselist.SelectedIndexChanged
    >>> If Databaselist.SelectedValue = "Test1" Then
    >>>
    >>> ReportList.Items.Clear()
    >>> ReportList.Items.Add("Test1Totals by Date Range")
    >>> ReportList.Items.Add("Test1Totals by name and Date Range")
    >>>
    >>> ElseIf Databaselist.SelectedValue = "Test2" Then
    >>>
    >>> ReportList.Items.Clear()
    >>> ReportList.Items.Add("Test2Totals by Date Range")
    >>> ReportList.Items.Add("Test2 Totals by name and Date Range")
    >>>
    >>> End If
    >>> End Sub
    >>>
    >>>

    >>
    >>

    >
    >
    Curt_C [MVP], Jan 27, 2005
    #7
  8. gv

    gv Guest

    How would I do this part on the client side?

    SmartNavigation didn't help.

    thanks
    Gerry


    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:eScn$...
    > Geez..so much for reading through everything....i didn't catch that at
    > all.
    >
    > One solution is to do everything on the client-side...which has its up and
    > down side.
    >
    > Another one is to turn on SmartNavigation which only works in IE and some
    > people have a lot of problems with it. Try putting SmartNaviation=true
    > in
    > the <%@ Page directive...
    > You should check out:
    > http://weblogs.asp.net/ksamaschke/archive/2003/04/27/6085.aspx or just do
    > a
    > google search for SmartNavigation
    >
    > Other that that, it's the nature of doing web programming...
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "gv" <> wrote in message
    > news:...
    >> If I do that, it works fine like I said but, flickers?
    >>
    >> I don't want it to flicker when I do this.
    >>
    >> thanks
    >> gv
    >>
    >>
    >> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    >> wrote in message news:...
    >> > Gv:
    >> > It works fine for me. Are you sure you have the AutoPostBack=true for

    > the
    >> > dropdownlist?
    >> >
    >> > karl
    >> >
    >> > --
    >> > MY ASP.Net tutorials
    >> > http://www.openmymind.net/
    >> >
    >> >
    >> > "gv" <> wrote in message
    >> > news:%238r%...
    >> >> Ok,
    >> >>
    >> >> Hi all, new to asp.net. Simple question
    >> >>
    >> >> with web forms
    >> >>
    >> >> I have a Dropdownlist and a listbox, I want to click on and item in
    >> >> the
    >> >> dropdownlist and show items in listbox. that simple
    >> >>
    >> >> I have this: I have two items in Dropdownlist. The Reportlist doesn't
    >> >> show
    >> >> the items ?
    >> >>
    >> >> I tried to set the Autopostback to true. This does work but, the page
    >> >> flickers
    >> >>
    >> >> Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    >> >> System.Object, ByVal e As System.EventArgs) Handles
    >> >> Databaselist.SelectedIndexChanged
    >> >> If Databaselist.SelectedValue = "Test1" Then
    >> >>
    >> >> ReportList.Items.Clear()
    >> >> ReportList.Items.Add("Test1Totals by Date Range")
    >> >> ReportList.Items.Add("Test1Totals by name and Date Range")
    >> >>
    >> >> ElseIf Databaselist.SelectedValue = "Test2" Then
    >> >>
    >> >> ReportList.Items.Clear()
    >> >> ReportList.Items.Add("Test2Totals by Date Range")
    >> >> ReportList.Items.Add("Test2 Totals by name and Date
    >> >> Range")
    >> >>
    >> >> End If
    >> >> End Sub
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
    gv, Jan 27, 2005
    #8
  9. gv

    Karl Seguin Guest

    GV:
    There's no magic bullet to achieve this...it involves knowing a lot about
    javascript, cross browser issues and using whatever ASP.Net offers to make
    it easier (which really isn't too much, sadly).

    One slightly clean solution is outlined here:
    http://www.15seconds.com/issue/010205.htm

    hope this sends you in the right direction.

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "gv" <> wrote in message
    news:O$...
    > How would I do this part on the client side?
    >
    > SmartNavigation didn't help.
    >
    > thanks
    > Gerry
    >
    >
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > wrote in message news:eScn$...
    > > Geez..so much for reading through everything....i didn't catch that at
    > > all.
    > >
    > > One solution is to do everything on the client-side...which has its up

    and
    > > down side.
    > >
    > > Another one is to turn on SmartNavigation which only works in IE and

    some
    > > people have a lot of problems with it. Try putting SmartNaviation=true
    > > in
    > > the <%@ Page directive...
    > > You should check out:
    > > http://weblogs.asp.net/ksamaschke/archive/2003/04/27/6085.aspx or just

    do
    > > a
    > > google search for SmartNavigation
    > >
    > > Other that that, it's the nature of doing web programming...
    > >
    > > Karl
    > >
    > > --
    > > MY ASP.Net tutorials
    > > http://www.openmymind.net/
    > >
    > >
    > > "gv" <> wrote in message
    > > news:...
    > >> If I do that, it works fine like I said but, flickers?
    > >>
    > >> I don't want it to flicker when I do this.
    > >>
    > >> thanks
    > >> gv
    > >>
    > >>
    > >> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > >> wrote in message news:...
    > >> > Gv:
    > >> > It works fine for me. Are you sure you have the AutoPostBack=true

    for
    > > the
    > >> > dropdownlist?
    > >> >
    > >> > karl
    > >> >
    > >> > --
    > >> > MY ASP.Net tutorials
    > >> > http://www.openmymind.net/
    > >> >
    > >> >
    > >> > "gv" <> wrote in message
    > >> > news:%238r%...
    > >> >> Ok,
    > >> >>
    > >> >> Hi all, new to asp.net. Simple question
    > >> >>
    > >> >> with web forms
    > >> >>
    > >> >> I have a Dropdownlist and a listbox, I want to click on and item in
    > >> >> the
    > >> >> dropdownlist and show items in listbox. that simple
    > >> >>
    > >> >> I have this: I have two items in Dropdownlist. The Reportlist

    doesn't
    > >> >> show
    > >> >> the items ?
    > >> >>
    > >> >> I tried to set the Autopostback to true. This does work but, the

    page
    > >> >> flickers
    > >> >>
    > >> >> Private Sub Databaselist_SelectedIndexChanged(ByVal sender As
    > >> >> System.Object, ByVal e As System.EventArgs) Handles
    > >> >> Databaselist.SelectedIndexChanged
    > >> >> If Databaselist.SelectedValue = "Test1" Then
    > >> >>
    > >> >> ReportList.Items.Clear()
    > >> >> ReportList.Items.Add("Test1Totals by Date Range")
    > >> >> ReportList.Items.Add("Test1Totals by name and Date

    Range")
    > >> >>
    > >> >> ElseIf Databaselist.SelectedValue = "Test2" Then
    > >> >>
    > >> >> ReportList.Items.Clear()
    > >> >> ReportList.Items.Add("Test2Totals by Date Range")
    > >> >> ReportList.Items.Add("Test2 Totals by name and Date
    > >> >> Range")
    > >> >>
    > >> >> End If
    > >> >> End Sub
    > >> >>
    > >> >>
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
    Karl Seguin, Jan 27, 2005
    #9
    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. blenderdude
    Replies:
    0
    Views:
    773
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    391
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    863
    Andrew de la Harpe
    May 3, 2004
  4. Simon Prince
    Replies:
    2
    Views:
    3,308
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  5. Chris Kettenbach

    Listbox selection to populate another listbox?

    Chris Kettenbach, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,633
    Chris Kettenbach
    Jun 16, 2005
Loading...

Share This Page