This is a migrated thread and some comments may be shown as answers.
Error in RadGrid when using RadDatePicker and KeyboardNavigation
4 Answers 91 Views
This is a migrated thread and some comments may be shown as answers.
Aaron Bauman
Top achievements
Rank 1
Aaron Bauman asked on 03 Apr 2012, 08:06 PM
Hello,
I have created a RadGrid that uses KeyboardNavigation for making changes.  Two of my columns are dates and use RadDatePickers for inline editing.  My third column is just a Notes column (text box).
When I hit [Enter]  to put a row into Edit Mode, move to the Notes text box and hit [Enter] I can save the row, or if I hit [Escape] I can cancel the edit.

If, however, my focus is on one of the two RadDatePickers and I hit [Enter] or [Escape] I get the following error:

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


<telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="true" AutoGenerateColumns="False"
            PageSize="15" AllowSorting="True" AllowMultiRowSelection="true" AllowPaging="True"
            AutoGenerateEditColumn="true" GridLines="None" Width="50%" Skin="Hay">
            <PagerStyle Mode="NumericPages" />
            <MasterTableView DataKeyNames="RecordID" AllowMultiColumnSorting="True" Width="100%"
                CommandItemDisplay="Top" Name="Customers" EditMode="InPlace">
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Name" FieldName="Name" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="Name" SortOrder="Ascending" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                    <telerik:GridBoundColumn UniqueName="Name" DataField="Name" HeaderText="Name" ReadOnly="true"
                        Visible="false" />
                    <telerik:GridDateTimeColumn UniqueName="StartDate" DataField="StartDate" HeaderText="Start Date"
                        ColumnEditorID="editorStartDate" DataFormatString="{0:M/d/yyyy}" />
                    <telerik:GridDateTimeColumn UniqueName="EndDate" DataField="EndDate" HeaderText="End Date"
                        ColumnEditorID="editorEndDate" DataFormatString="{0:M/d/yyyy}" />
                    <telerik:GridBoundColumn UniqueName="Notes" DataField="Notes" HeaderText="Notes"
                        ColumnEditorID="editorNotes" />
                </Columns>
            </MasterTableView>
            <ClientSettings AllowKeyboardNavigation="true">
                <ClientEvents OnRowClick="RowClick" OnRowDblClick="RowDblClick" OnGridCreated="GridCreated"
                    OnCommand="GridCommand" />
                <KeyboardNavigationSettings EnableKeyboardShortcuts="true" AllowSubmitOnEnter="true"
                    AllowActiveRowCycle="true" CollapseDetailTableKey="LeftArrow" ExpandDetailTableKey="RightArrow" />
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:GridDateTimeColumnEditor ID="editorStartDate" runat="server" />
        <telerik:GridDateTimeColumnEditor ID="editorEndDate" runat="server" />
        <telerik:GridTextBoxColumnEditor ID="editorNotes" runat="server" />

Has anyone else seen this one?

Thanks,
-Aaron

4 Answers, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 06 Apr 2012, 10:46 AM
Hello Aaron,

We are aware of this problem in Q1 2012 and we manage to solve this. It is working correct with the latest builds. I would suggest you to download the Service Pack that will be available after 14th of April if you need to use it on production environment.

Regards,
Vasil
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
Lynn
Top achievements
Rank 1
answered on 27 Apr 2012, 04:25 PM
Since this thread was marked Answered, I created a new thread for this problem.

link to thread
0
Avi
Top achievements
Rank 1
answered on 02 Oct 2012, 08:40 PM
I have a editable radgrid with Inplace Editmode. I have a date column which has a DatePicker.
In the edit mode, after selecting a different date from date picker, the datapicker still holds back to the old date.
In the event Grid_UpdateCommand, DatePicker.SelectedDate is not updated with the new selected date. It keeps showing the old date. All this is in a widget in Sitefinity platform 3.7. Has anyone else experienced this issue? Is there some thing specific to be done to make this work?

Here is what my code looks like -
.ascx file -
<telerik:GridDateTimeColumn UniqueName="StartDate" PickerType="DatePicker" HeaderText="Start Date" DataField="StartDate" DataFormatString="{0:MM/dd/yyyy}" EditDataFormatString="MM/dd/yyyy"> <HeaderStyle Width="105px" /><ItemStyle Width="110px" /></telerik:GridDateTimeColumn>


.cs code behind -
private void Grid_UpdateCommand(object sender, GridCommandEventArgs e)
{
 GridEditableItem editItem = e.Item as GridEditableItem;
 RadDatePicker StartDate = (editItem["StartDate"].Controls[0] as RadDatePicker);
  //StartDate.SelectedDate doesn't update to the new date I just selected
}

Thanks
Avi

0
Vasil
Telerik team
answered on 05 Oct 2012, 07:17 AM
Hello Avi,

I am not aware if such problem was existing back in Q2 2009. Check if you got any JavaScript error in your page, that may prevent the value to be updated into the submit input.
Check if the StartDate.DateInput.SelectedDate is correct in your case. You could also
attach OnDateSelected handler to RadDatePicker and see if it ever fires. Also try to place a RadDatePicker outside your grid to see if its value is updated on postback.
Also check the binding of the grid. If you rebind the grid before the update command all controls inside will get the initial value from the database.

Kind regards,
Vasil
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
Aaron Bauman
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Lynn
Top achievements
Rank 1
Avi
Top achievements
Rank 1
Share this question
or