How to programmatically create and use a list of checkboxes from ASP.NET?

前端 未结 7 1244
礼貌的吻别
礼貌的吻别 2021-01-19 10:37

I have a page with a table of stuff and I need to allow the user to select rows to process. I\'ve figured out how to add a column of check boxes to the table but I can\'t se

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-19 10:58

    Add them in an override of the CreateChildControls method of the Page. Be sure to give them an ID! This way they get added to the control tree at the correct time.

    IMHO The best way would be to use DataBound Templated Control though, i.e. something like a ListView (in .NET 3.5). then in pageload after postback traverse all items in the databound control and use item.FindControl to get at the actual checkbox.

提交回复
热议问题