How to Create Dynamic DropDownLists in ASP.NET

How to Create Dynamic DropDownLists in ASP.NET

CheapASPNETHostingReview.com | Best and cheap ASP.NET hosting. In this post I will tell you how to create Dynamic DropDownLists in ASP.NET

Object:

  • Create dropdownlist dynamically with autopostback property true
  • Keep dropdownlist during postback
  • Maintain selected value during postback.

Here is the sample for this :

To Create Dynamic Dropdownlist:

To retrieve value on button click:

Right Now, No output because dynamic controls are lost in postback then what to do.
So we need to save dynamic controls value and generate dynamic controls again.we need to maintain viewstate.