DropDownList in FormView binding

后端 未结 3 1887
情深已故
情深已故 2021-02-13 23:34

I want to bind dropdownlist to List, in code behind.

 

        
3条回答
  •  余生分开走
    2021-02-14 00:11

    You can populate the DropDownList with another DataSource, assuming the valid values are in the database. Check out this video:

    http://msdn.microsoft.com/en-us/data/cc546554.aspx

    It's using an EntityDataSource instead of an ObjectDataSource, but the principle should still work.

    If you want a "(none)" type option for null, see section "Converting Null in Template Fields" on this page:

    http://msdn.microsoft.com/en-us/library/ms366709.aspx

    Specifically:

    
            (none)
    
    

    Notice the the "AppendDataBoundItems" attribute and the "asp:ListItem" element.

提交回复
热议问题