How to Add datepicker in asp.net Gridview control

前端 未结 1 1551
别那么骄傲
别那么骄傲 2020-12-20 10:31

I am trying to add datepicker into a Asp.net Gridview control with column name (cheque_date), when i hardcode the id of Gridview column of a particular row it works fine but

相关标签:
1条回答
  • 2020-12-20 10:58

    You should change your script to this. It is also better to make a function and not place it inside the endRequest. Because as your code is now it will not bind the datepicker on first load, but only after a UpdatePanel update. Note the use of ClientID

    <script type="text/javascript">
    
        var prm = Sys.WebForms.PageRequestManager.getInstance();
    
        prm.add_endRequest(function () {
            bindDatePicker();
        });
    
        bindDatePicker();
    
        function bindDatePicker() {
            $("#<%=gvBankPayment.ClientID %> .myDatePickerClass").focusin(function () {
                $(this).datepicker({
                    dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, yearRange: '1950:2013', yearRange: '1950:2050'
                });
            });
        }
    </script>
    
    0 讨论(0)
提交回复
热议问题