This is a migrated thread and some comments may be shown as answers.

DatePicker in Grid

5 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
etu
Top achievements
Rank 1
etu asked on 25 Aug 2008, 10:47 AM
There is a datepicker in grid as templatecolumn.In edit mode it is working, but i dont know how to show the selected date in display mode of grid.
i wrote code below but it gives  "Specified cast is not valid." error.

<radG:GridTemplateColumn HeaderText="Date" SortExpression="Date" UniqueName="Date" ItemStyle-Width="12.5%">

<ItemTemplate>

<asp:Label runat="server" ID="lblDate" Text='<%# Eval("Date") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<radCln:RadDatePicker runat="server" ID="datePicker" SelectedDate='<%# Bind("Date") %>'></radCln:RadDatePicker>

</EditItemTemplate>

</radG:GridTemplateColumn>


5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Aug 2008, 11:17 AM
Hello etu,

Try replacing the SelectedValue property of the RadDatePicker with DbSelectedValue property and then bind it to the DataSource. Rather than using a Template column, a better suggestion would be to use a GridDateTimeColumn in the Grid as shown below, which will allow the user to select a date from the DatePicker in EditMode and display the date in NormalMode.
aspx:
<telerik:GridDateTimeColumn DataField="date" UniqueName="date">         
</telerik:GridDateTimeColumn> 

Thanks
Princy
0
etu
Top achievements
Rank 1
answered on 25 Aug 2008, 11:46 AM
But in my grid GridDateTimeColumn is not avaliable.
Do i have to install or upgrade my rad controls?
0
Shinu
Top achievements
Rank 2
answered on 25 Aug 2008, 12:09 PM
Hello etu,

Did you try with the DbSelectedValue property of the DatePicker as suggested by Princy? I think that should solve the issue. Refer to this KB article. However, to use the GridDateTimeColumn you will have to upgrade to the latest version.
For information on upgrading to later versions go through the following link.
Updating RadControls for ASP.NET to another version or license

Shinu
0
etu
Top achievements
Rank 1
answered on 25 Aug 2008, 12:37 PM
But there is no DbSelected property in my raddatepicker as well.It means i have to upgrade my RadControls.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Aug 2008, 01:03 PM
Hi etu,

I am sorry. Try using DbSelectedDate instead of DbSelectedValue. Also this property will not come along with the intelliscense. You just have to type manually and bind the value. Here is how I implemented it.

ASPX:
<telerik:GridTemplateColumn UniqueName="DateCol"  DataField="DateCol"  HeaderText="DateCol"  > 
                     <ItemTemplate> 
                         <telerik:RadDatePicker ID="RadDatePicker2" DbSelectedDate ='<%#Eval("Date") %>' runat="server"
                         </telerik:RadDatePicker> 
                     </ItemTemplate> 
                    </telerik:GridTemplateColumn> 


Thanks
Shinu.
Tags
Grid
Asked by
etu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
etu
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or