Dynamically created DropDownList loses ListItems on Postback

前端 未结 5 1929
情书的邮戳
情书的邮戳 2021-01-18 05:53

I have a page that contains some dynamically created controls (TextBox and DropDownList). When a postback occurs, the TextBoxes keep their values, but the DropDownLists lose

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 06:24

    I have found the solution that will allow me to keep the viewstate across postbacks. It's to call TrackViewState of the ItemCollection.

    CType(ddl.Items, IStateManager).TrackViewState()
    

    Thanks to all for your help.

    This is the working solution:

    <%@ Page Language="VB"%>
    
    
    
    
    
    
      
    
    
      

提交回复
热议问题