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

Bind Date to RadDatePicker

1 Answer 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 05 May 2012, 04:42 PM
I have a radgrid with a datepicker and I can bind the raddatepicker when a dae exists in the database, but the date to start out is always NULL and can be left null, right now I get an error on bind when trying to bind if the db is null, how can I bind if a date exists but if nothing exists show no date.   In my sql code I can do a
Case when dtRecoverTemp IS NULL then '' ELSE dtRecoverTemp END dtRecoverTemp,

but what happens then is it puts in 1900-01-01 for date and I want it to show nothing.

<telerik:GridTemplateColumn HeaderText="TEMP_DT">
                                                                    <ItemTemplate>
                                                                            <telerik:RadDatePicker ID="DatePicker" runat="server" PopupDirection="BottomRight" AutoPostBack="false" Width="120px" EnableShadows="true" ShowPopupOnFocus="true" 
                                                                            DatePopupButton-Visible="false" DateInput-CssClass="pointer" SkinID="Web20" SelectedDate='<% #bind ("dtRecoverTemp") %>' >
                                                                            <DateInput runat="server" DisplayDateFormat="yyyy/MM/dd" DateInput-CssClass="pointer"></DateInput></telerik:RadDatePicker>
                                                                    </ItemTemplate>
                                                                </telerik:GridTemplateColumn>


1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 05 May 2012, 04:52 PM
Ok, after further research I found the solution, delete this.
<ItemTemplate>
      <telerik:RadDatePicker ID="DatePicker" runat="server" PopupDirection="BottomRight" AutoPostBack="false" Width="120px"          EnableShadows="true" ShowPopupOnFocus="true" 
DatePopupButton-Visible="false" DateInput-CssClass="pointer" SkinID="Web20" DbSelectedDate='<%# bind("dtRecoverTemp") %>'>
 <DateInput runat="server" DisplayDateFormat="yyyy/MM/dd" DateInput-CssClass="pointer"></DateInput></telerik:RadDatePicker>
</ItemTemplate>


this allows nulls or a date, let me know if this is not the solution.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Share this question
or