ASP:DropDownList in ItemTemplate: Why is SelectedValue attribute allowed?

后端 未结 2 1317
逝去的感伤
逝去的感伤 2020-12-20 13:31

This piece of code


             


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 13:43

    It means you cannot set it through the designer.

    The correct way is:

    
        
        
        
    
    

    The reason the bound method works is because the value isn't selected in design mode but at runtime after the control is bound to a datasource

    The DropDownList.SelectedValue method is meant to be applied at runtime hence the error about not being able to set it 'decoratively'

提交回复
热议问题