This is a migrated thread and some comments may be shown as answers.
RadGrid issue: after postback, contents of datetime column are being cleared onFocus
5 Answers 84 Views
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 1
Lynn asked on 27 Apr 2012, 07:36 PM
Hello,

There is a very similar problem with <GridDateTimeColumn>, as this message: http://www.telerik.com/community/forums/reply-thread.aspx?messageId=2088875&threadId=530174 .

However, this problem still happens after the Telerik.Web.UI_2012_1_424_Dev release build.


My problem:

I have a grid with EditForm edit mode enabled.

When I select an editable field that fires a OnTextChanged post back event, if I give focus to an editable <GridDateTimeColumn> field, I get a problem.

Prior to this hotfix, I would get an error the same error: "Text property cannot be set. String was not recognized as a valid DateTime."

After this hotfix, what happend is when I focus an editable <GridDateTimeColumn> field, the contents of the field disappear. Actually, the contents appear to first be selected, then they disappear. Focusing on other types of columns does not do this.

Normal behavior (and expected), as when tabbing from field to field without this post back event, the items are selected. But the selection is not removed.

Here are the two date/time column definitions in my grid, demonstrating the problem:

<telerik:GridDateTimeColumn DataField="ValidFromDate"
    FilterControlAltText="Filter ValidFromDate column" HeaderText="Valid From"
    UniqueName="ValidFromDate" DataFormatString="{0:MM/dd/yyyy}"
    MinDate="1901-01-01" MaxDate="9999-12-31 23:59:59.999999">
</telerik:GridDateTimeColumn>
 
<telerik:GridDateTimeColumn DataField="ValidToDate"
    FilterControlAltText="Filter ValidToDate column" HeaderText="Valid To"
    UniqueName="ValidToDate" DataFormatString="{0:MM/dd/yyyy}"
    MinDate="1901-01-01" MaxDate="9999-12-31 23:59:59.999999">
</telerik:GridDateTimeColumn>


Here is the column that fires the OnTextChanged event while in Edit-Mode (see <EditItemTemplate>):

<telerik:GridTemplateColumn HeaderText="Override Discount $" UniqueName="OverrideDiscount">
     
    <ItemTemplate>
         
        <telerik:RadNumericTextBox NumberFormat-DecimalDigits="2"
            ID="txtOverrideDiscountDsp" runat="server"
            gmNumberFormat-AllowRounding="False" Type="Currency" Width="52px"
            BackColor="Transparent" BorderStyle="None"
            Value='<%#CoalesceNumericValuesToRadNumberControl(DataBinder.Eval(Container.DataItem, "UpdateCustomerPrice"), null) %>'>
        </telerik:RadNumericTextBox>              
         
    </ItemTemplate>
                     
    <EditItemTemplate>
        <telerik:RadNumericTextBox NumberFormat-DecimalDigits="2" ID="txtOverrideDiscount" runat="server"
            AutoPostBack="true" OnTextChanged="txtOverrideDiscount_OnTextChanged"
            gmNumberFormat-AllowRounding="False" Type="Currency"
            Value='<%#CoalesceNumericValuesToRadNumberControl(DataBinder.Eval(Container.DataItem, "CustomerPrice"), null) %>'>
        </telerik:RadNumericTextBox>
    </EditItemTemplate>
 
</telerik:GridTemplateColumn>

Thanks

saxan.sartar (at) gmail (dot) com 

5 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 02 May 2012, 09:05 AM
Hi Lynn,

I have tried to replicate the issue but to no avail. Attached to this message you will find the project I used for testing. I have assembled a sample video showing the behavior on my side.

In order to further investigate you could alter the attached project or send us a sample running project demonstrating the unwanted behavior.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adam
Top achievements
Rank 1
answered on 02 May 2012, 04:35 PM
We're seeing the same after deploying version 2012.1.215.40.

Repro steps:
Click edit command on a row (in our case an image button)
Click into the input on a GridDateTimeColumn
A postback is fired from the click and the following exception is seen. Note that the dates do display correctly in the grid (both in view and edit mode).

System.InvalidCastException: Text property cannot be set. String was not recognized as a valid DateTime.
at Telerik.Web.UI.RadDateInput.RangeTextProperty(String value)
at Telerik.Web.UI.RadDateInput.set_Text(String value)
at Telerik.Web.UI.DatePickingInput.LoadPostData(String postDataKey, NameValueCollection postCollection)
at Telerik.Web.UI.RadWebControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 

<telerik:RadGrid ID="rgDiscountDateRules" runat="server" GridLines="None" Skin="Windows7"
                                                OnNeedDataSource="rgDiscountDateRules_NeedsDataSource" OnCancelCommand="rgDiscountQtyRules_CancelCommand"
                                                OnDeleteCommand="rgDiscountDateRules_DeleteCommand" AllowPaging="True"
                                                AutoGenerateColumns="False" CellSpacing="0" >
                                                    <MasterTableView DataKeyNames="DiscountDateRuleID" EditMode="InPlace">
                                                        <RowIndicatorColumn>
                                                            <HeaderStyle Width="20px"></HeaderStyle>
                                                        </RowIndicatorColumn>
                                                        <ExpandCollapseColumn>
                                                            <HeaderStyle Width="20px"></HeaderStyle>
                                                        </ExpandCollapseColumn>
                                
                                                        <Columns>

                                                             <telerik:GridTemplateColumn>
                                                                <ItemTemplate>
                                                                    <asp:ImageButton ID="ibtnDiscountDateRule_Edit" AlternateText="Edit this rule" runat="server" ImageUrl="/images/editItem.gif"  CommandName="Select" />
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                   <asp:ImageButton ID="ibtnDiscountDateRule_Update" runat="server" CommandName="Update" ImageUrl="/images/reports/save.gif" AlternateText="Update Rule" />
                                                                    &nbsp;
                                                                    <asp:ImageButton ID="ibtnDiscountDateRule_Cancel" runat="server" CommandName="Cancel" ImageUrl="/images/Cancel-2-icon-16.png" AlternateText="Cancel Edit" />

                                                                </EditItemTemplate>
                                                            </telerik:GridTemplateColumn>

                                                           <telerik:GridDateTimeColumn DataField="StartDate"   HeaderText="Start" DataFormatString="{0:d}" UniqueName="DiscountDateRule_StartDate" PickerType="DatePicker" />
                                                           <telerik:GridDateTimeColumn DataField="EndDate"  HeaderText="End" DataFormatString="{0:d}" UniqueName="DiscountDateRule_EndDate" PickerType="DatePicker" />

                                                            <telerik:GridTemplateColumn HeaderText="Discount">
                                                                <ItemTemplate>
                                                                <asp:Label ID="lblDiscountDateRuleAmount" runat="server" />
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <telerik:RadNumericTextBox Type="Currency" NumberFormat-DecimalDigits="2"
                                                                        ShowSpinButtons="false"  Width="50px" ID="rntbDiscountAmount_Date"
                                                                        runat="server"  InvalidStyleDuration="100">
                                                                        <NumberFormat AllowRounding="True" KeepNotRoundedValue="False" />
                                                                    </telerik:RadNumericTextBox>
                                                                </EditItemTemplate>
                                                               
                                                            </telerik:GridTemplateColumn>
                                                          
                                                            <telerik:GridButtonColumn Text="Delete" ButtonType="ImageButton" ImageUrl="/images/icon_delete.gif" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to delete this date range discount rule?" CommandName="Delete"  />

                                                        </Columns>

                                                        <EditFormSettings>
                                                        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                                        </EditFormSettings>
                                                     </MasterTableView>

                                                        <FilterMenu EnableImageSprites="False"></FilterMenu>
                                                        <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true"  />
                                                </telerik:RadGrid>

0
Antonio Stoilkov
Telerik team
answered on 07 May 2012, 07:55 AM
Hello Adam,

I have updated the page I use for testing with the newly provided code but I could not replicate the issue. I have attached the aspx page and assembled a sample video showing the behavior on my side.

In order to help you further you could open a formal ticket and attach an isolated project replicating the issue.

Greetings,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Adam
Top achievements
Rank 1
answered on 07 May 2012, 03:19 PM
I narrowed down the issue to:
<ClientSettings EnablePostBackOnRowClick="true"  />

In the previous version we were using it appears that enablePostBackOnRowClick would not raise a post back when clicking in the date time picker and the new version triggers a postback when clicking the date picker input box (note clicking the calendar icon on the date picker does not fire the post back, only the input field).
0
Antonio Stoilkov
Telerik team
answered on 10 May 2012, 07:13 AM
Hi Adam,

I have assembled a sample video showing that with the version 2012.1.215 the issue could not be replicated. You could observe clicking in the input controls does not cause postback. I have also tested the scenario with different dll files but without success.

Additionally, I am attaching the aspx page with the dll files.

Regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Lynn
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Adam
Top achievements
Rank 1
Share this question
or