Refresh a ListBox in ASP.Net with C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to create a .Net page with 2 controls. The 1st is a dropdown being
populated from a database. The 2nd control is a listbox which is also
populated from the same database but the content is dependent upon a
selection from the dropdown control. I have no DB issues but being new to
..Net want a slick way to refresh my listbox control without taking a round
trip to the server to requery my DB stored Proc each time I select a
different droplist item.
In classic ASP i have done this by using <div> tags, one for each subset of
data and making them dynamically visible or not depending on the dropdown
list selection but feel this is an overhead and there must be a better more
efficient way to handle this with client side script.

Any help greatly appreciated...
 
Unless I am mistaken, the ASP.Net way is to move back to the server side, so
that your first control has AutoPostback set to true, at which point you
populate the second from within the first's selection changed event handler.

If there isn't much choice in the first dropdown, for example, then you
could "cache" all data from all possible instances on client side script,
then do this all client side. It sounds like your method already did this...
 
Back
Top