Dynamically (programatically) adding check boxes and checkedchanged events

前端 未结 8 489
情歌与酒
情歌与酒 2020-12-19 18:21

I am having a bit of a problem adding a few check boxes and an event handler programatically. The check boxes all appear fine, but they don\'t do anything when clicked. Does

相关标签:
8条回答
  • 2020-12-19 18:55

    Make sure to verify you are doing the following:

    • The same list of checkbox is being added on both the initial load and further postbacks
    • You set a different ID to each checkbox
    • Verify you are getting a postback (set a break point in Page Load)
    • The controls are added to the page on Page Load, or even better on Page Init

    If you are trying to do something different than that, update us with more info.

    0 讨论(0)
  • 2020-12-19 18:55

    You can get value by Request["controlname"] method when you inserted control in runtime.You must set Unique ID for each control.

    However you can use CheckBoxList as an alternative instead of dynamically added checkboxes

    0 讨论(0)
提交回复
热议问题