Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Calendar / Data Binding

The demo illustrates how RadMonthYearPicker can be used inside an edit template of a template column. Additionally, the DbSelectedDate property of the month year picker is of nullable type and hence supports null values.
RadMonthYearPicker in EditItemTemplate of GridTemplateColumn RadMonthYearPicker embedded in RadListView EditItemTemplate

  • Binding a RadMonthYearPicker to a data source is easily provided through the DbSelectedDate property. It works almost like the SelectedDate one, but will not throw an exception when it is given a null value.

    The example demonstrates binding a RadGrid and a RadListView controls to a DataTable with dates, containing null values. Binding the date for the MonthYearPicker in GridTemplateColumn and listview EditItemTemplate is done via the DbSelectedDate property.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page CodeFile="DefaultCS.aspx.cs" Language="c#" Inherits="Telerik.Web.Examples.Calendar.MonthYearPicker.DataBinding.DefaultCS" %>

    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="CS" ShowSkinChooser="true" OnSkinChanged="Header1_SkinChanged">
        </qsf:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <div class="bigModule">
            <div class="bigModuleBottom">
                The demo illustrates how RadMonthYearPicker can be used inside an edit template
                of a template column. Additionally, the DbSelectedDate property of the month year
                picker is of nullable type and hence supports null values.
            </div>
        </div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="ListViewPanel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <table>
            <tr>
                <td style="width: 360px;" valign="top">
                    <a style="color: Maroon;">RadMonthYearPicker in EditItemTemplate of GridTemplateColumn
                    </a>
                    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
                        OnUpdateCommand="RadGrid1_UpdateCommand">
                        <MasterTableView Width="100%" EditMode="InPlace">
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Available dates" UniqueName="TemplateColumn">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="date" Text='<%# Eval("Dates", "{0:MM/yyyy}") %>'>
                                        </asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadMonthYearPicker ID="picker1" MinDate="01/2010" runat="server" DbSelectedDate='<%# Bind("Dates") %>'>
                                        </telerik:RadMonthYearPicker>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="Img/Edit.gif" UpdateImageUrl="Img/Update.gif" CancelImageUrl="Img/Cancel.gif" />
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </td>
                <td style="width: 30px">
                </td>
                <td style="height: 100px; width: 360px">
                    <a style="color: Maroon;">RadMonthYearPicker embedded in RadListView EditItemTemplate
                    </a>
                    <asp:Panel ID="ListViewPanel" runat="server">
                        <telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="Dates" OnNeedDataSource="RadListView1_NeedDataSource"
                            OnItemCommand="RadListView1_ItemCommand">
                            <LayoutTemplate>
                                <div class="RadListView RadListView_<%# Container.Skin %>">
                                    <table cellspacing="0" cellpadding="0" style="width: 100%;">
                                        <thead>
                                            <tr class="rlvHeader">
                                                <th>
                                                    Available dates
                                                </th>
                                                <th>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr id="itemPlaceholder" runat="server">
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <tr class="rlvI">
                                    <td>
                                        <asp:Label runat="server" ID="date" Text='<%# Eval("Dates", "{0:MM/yyyy}") %>'>
                                        </asp:Label>
                                    </td>
                                    <td>
                                        <asp:ImageButton ID="Button1" runat="server" CommandName="Edit" ImageUrl="Img/Edit.gif" />&nbsp;
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <tr class="rlvIEdit">
                                    <td>
                                        <telerik:RadMonthYearPicker ID="picker1" MinDate="01/2010" runat="server" DbSelectedDate='<%# Bind("Dates") %>'>
                                        </telerik:RadMonthYearPicker>
                                    </td>
                                    <td>
                                        <asp:ImageButton ID="Button1" runat="server" CommandName="Update" AlternateText="Update" ImageUrl="Img/Update.gif" />
                                        <asp:ImageButton ID="Button2" runat="server" CommandName="Cancel" AlternateText="Cancel" ImageUrl="Img/Cancel.gif" />
                                    </td>
                                </tr>
                            </EditItemTemplate>
                        </telerik:RadListView>
                    </asp:Panel>
                </td>
            </tr>
        </table>
        <qsf:Footer ID="Footer1" runat="server"></qsf:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451