Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
DatePickerProvider
posted

I am attempting to build a datechooser in a webdatagrid using the datepickerprovider and constructing the whole thing dynamically in the code behind. based on a flag built into the column when the datagrid is dynamically created as well.  When I do this the control seems to be created correctly however, when I click the drop down arrow on the right side of the textbox the calendar is not displayed. This control is built in an updatepanel if that matters. If this can't work can someone give me a suggestion on how to build the same piece using a native asp calendar control?  Thank you for your time!

 

  • 18204
    Suggested Answer
    Offline posted

    Hi Neel,

     

    Please make sure you are creating the DatePickerProvider early enough in the ASP.NET Page Life-Cycle.  If it is being created too late, the drop down may not be created successfully.  Please see my attached sample using your code that demonstrates how this may be affecting the provider.  In my sample, you can comment out the call to BuildDatePickerProvider during Page_Load and it will be called in Page_PreRender and will no longer appear when pressing the drop down button.

     

    If you need further assistance with this, please let me know and I will be glad to help.

    WDG_DynamicDatePickerProvider.zip
  • 30
    posted

    Here is the code:

    Protected

    Sub BuildDatePickerProvider(ByVal required As Boolean, ByVal columnName As String)

          

    Dim dtprovider As New DatePickerProvider()

            dtprovider.ID = "date_" & columnName

            dtprovider.EditorControl.OpenCalendarOnFocus =True

    'dtprovider.EditorControl.EnableEmbeddedJavaScript = True

            EditorProviders.Add(dtprovider)

    Dim columnSetting As EditingColumnSetting = New EditingColumnSetting()

    'Dim rowSetting As RowAddingColumnSetting = New RowAddingColumnSetting()

            columnSetting.ColumnKey = columnName

            columnSetting.EditorID = dtprovider.ID

    'rowSetting.ColumnKey = columnName

    'rowSetting.EditorID = dtprovider.ID

    'rowSetting.DefaultValue = Date.Now()

     'If required Then

     '    Dim validator As New AJAXWorkaround.RequiredFieldValidator()

     '    validator.ID = "validator_" & columnName

    '    validator.ErrorMessage = "Input is required for this field!"

    '    validator.ControlToValidate = Me.ID

    '    Me.Controls.Add(validator)
    '    columnSetting.ValidatorID = validator.ID

    '    rowSetting.ValidatorID = validator.ID

    '    Me.Parent.Controls.Add(validator)

    'End If

      Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(columnSetting)

     'Behaviors.EditingCore.Behaviors.RowAdding.ColumnSettings.Add(rowSetting)