Link to home
Start Free TrialLog in
Avatar of 1jaws
1jawsFlag for United States of America

asked on

calendar question

I have this code.. and shows this format when I picked the date, I want yyyy,mm,dd format how can I do that? Second, while reading back from database how would I select that date whatever comes from database?

<radCln:RadDatePicker ID="pickdate" runat="server" Width="140px" AutoPostBack="true"
                                     MinDate="01/01/1000" MaxDate="01/01/3000">
                                    <Calendar runat="server">
                                        <SpecialDays>
                                            <radCln:RadCalendarDay Repeatable="Today" />
                                        </SpecialDays>
                                    </Calendar>
                                </radCln:RadDatePicker>
Avatar of Anil Golamari
Anil Golamari
Flag of United States of America image

http://www.telerik.com/products/aspnet-ajax/calendar.aspx

Above is the link with information you may use to work on. You can set you data format property for the control in which ever form you want.
Avatar of 1jaws

ASKER

yes, I looked at that and couldnt figure it out myself..
http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/custompopup/defaultcs.aspx

<li>dateinput format
                    <telerik:RadComboBox ID="rcbDateFormat" runat="server" AutoPostBack="true" Width="100px">
                        <Items>
                            <telerik:RadComboBoxItem Text="d" Value="d" Selected="true" />
                            <telerik:RadComboBoxItem Text="D" Value="D" Selected="true" />
                            <telerik:RadComboBoxItem Text="dd/MMM/yyyy" Value="dd/MMM/yyyy" />
                            <telerik:RadComboBoxItem Text="dd/MMM/yy" Value="dd/MMM/yy" />
                        </Items>
                    </telerik:RadComboBox>
                </li>
Avatar of 1jaws

ASKER

I dont use <telerik: I use <radCln  so I dont know how will I use that ..
ASKER CERTIFIED SOLUTION
Avatar of Anil Golamari
Anil Golamari
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1jaws

ASKER

OK I just added to dateformat to above it worked.. now I need to read from database using reader to select the date comes it comes back from the database.. it comes back from db like this
2010-06-22 00:00:00.000  I need to be able to select this date...
private void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e)  
{  
    RadDatePicker picker = (RadDatePicker) e.Item.FindControl("picker1");  
 
    object newDate = ((DateTime)picker.DbSelectedDate).ToString("dd/MM/yyyy");  
    DataSource.Rows[e.Item.DataSetIndex]["Dates"] = newDate;  
 
    DataGrid1.EditItemIndex = -1;  
    RebindGrid();  
}  

I am also pasting the site where I got this I think you should be able to go get it work from this information.

http://www.telerik.com/community/forums/aspnet/calendar/datapicker-not-insert-time-in-database.aspx
Avatar of 1jaws

ASKER

I am not using datagrid, it is just outside the grid...
Avatar of 1jaws

ASKER

if(reader["Date"]!= null)
                           pickdate.SelectedDate = String.Format("{0:yyyy/MM/dd}", (DateTime)reader["Date"]);

something like but it complains for the right side the =
<EditItemTemplate>
    <telerik:RadDatePicker id="picker1" MinDate="2006/1/1" runat="server" DbSelectedDate='<%# Bind("Dates") %>'>
    </telerik:RadDatePicker>
</EditItemTemplate>

UpdateCommand="UPDATE [tblAgenda]  
SET [DateWorkshop] = CAST((CAST(DATEPART(year,@DateWorkshop) AS VARCHAR(4)) + '-' + CAST(DATEPART(month,@DateWorkshop) as VARCHAR(2)) + '-' + CAST(DATEPART(day,@DateWorkshop) AS VARCHAR(2))) as VARCHAR(10))  
WHERE [AgendaID] = @AgendaID


And also the link which I pasted in my previous comment should help you in binding date with database take a look at it.
Avatar of 1jaws

ASKER

Not using datagrid... and above code I just deleted   String.format part and it works.. thanks for the helpp..
ur welcome