c# - Dynamically generate DatePicker controls on the basis of Database values -
i have multiple rows inside database table
id qid qname qtext qtype version 5 10025 datefrom daterange 1 5 10026 dateto daterange 1
i want dynamically generate datepicker
controls on basis of values database table. question use qname
, qid
differentiate between (smaller id) , (greater id) generate controls, , apply comparevalidator
to check date range validation
. loop through controls on basis of id.
here code generate controls.
case "daterange": raddatepicker rdpdatefrom = new raddatepicker(); rdpdatefrom.cssclass = "form-control form-control-item"; rdpdatefrom.id = "rdpdatefrom" + j.tostring() + "-" + counter; rdpdatefrom.autopostback = false; rdpdatefrom.datepopupbutton.visible = true; rdpdatefrom.showpopuponfocus = true; rdpdatefrom.enablescreenboundarydetection = true; rdpdatefrom.maxdate = datetime.now; txtc1.controls.add(rdpdatefrom); raddatepicker rdpdateto = new raddatepicker(); rdpdateto.cssclass = "form-control form-control-item"; rdpdateto.id = "rdpdateto" + j.tostring() + "-" + counter; rdpdateto.autopostback = false; rdpdateto.datepopupbutton.visible = true; rdpdateto.showpopuponfocus = true; rdpdateto.enablescreenboundarydetection = true; rdpdateto.maxdate = datetime.now; txtc1.controls.add(rdpdateto); comparevalidator cvdpdate = new comparevalidator(); cvdpdate.id = "cvdpdate" + j.tostring() + "-" + counter; cvdpdate.controltocompare = "rdpdatefrom" + j.tostring() + "-" + counter; cvdpdate.controltovalidate = "rdpdateto" + j.tostring() + "-" + counter; cvdpdate.operator = validationcompareoperator.greaterthanequal; cvdpdate.display = validatordisplay.dynamic; cvdpdate.errormessage = "end date must equal or greater start date - please correct dates."; txtc1.controls.add(cvdpdate); break;
Comments
Post a Comment