The CheckBox control is selected by default, and the implementation code of the selected status is always obtained at the time of submission. The checkbox control
Write a project and obtain the data binding value Checkbox from the database. The binding method is as follows:
// OverTime settings Data Binding protected void CheckBoxBind () {OverTimeBLL overTimeBll = new OverTimeBLL (); List <OverTime> overTimeList = new List <OverTime> (); overTimeList = overTimeBll. getAll (); if (overTimeList. count> 0) {// bind the page information txtID. text = overTimeList [0]. ID. toString (); if (overTimeList [0]. isEarlyValid. toLower () = "true") cbIsEarlyValid. checked = true; if (overTimeList [0]. isLaterValid. toLower () = "true") cbIsLaterValid. checked = true; if (overTimeList [0]. isOnlyHoliday. toLower () = "true") cbIsOnlyHoliday. checked = true; if (overTimeList [0]. isUseTime. toLower () = "true") cbIsUseTime. checked = true; if (overTimeList [0]. isUseNum. toLower () = "true") cbIsUseNum. checked = true; txtMinDuration. text = overTimeList [0]. minDuration. toString ();}}
Then add the CheckBoxBind () method to the protected void Page_Load (object sender, EventArgs e) method, but if a CheckBox is selected during submission, the result will always be that the checked attribute of the checkBox is True. Later, I tried it again and found that I was negligent, as long as I put the CheckBoxBind method in if (! This. Page. IsPostBack.
The Code is as follows:
If (! This. Page. IsPostBack) {remindResult. Text = GetRemind (); // The Page data is bound to CheckBoxBind ();}
The above CheckBox control is selected by default. The implementation code that always gets the selected status upon submission is all the content shared by Alibaba Cloud. I hope you can give us a reference and support the help house.