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

Calender Control Filter RadGrid

1 Answer 64 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 2
Allan asked on 01 Dec 2010, 11:57 PM
Is it possible to use a RadCalender to filter a RadGrid connected to a SQLDataSource?

This is how simple it is using standard .NET controls:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
        SelectCommand="SELECT [name], [id], [dtime] FROM [test] WHERE ([dtime] = @dtime)">
        <SelectParameters>
            <asp:ControlParameter ControlID="Calendar1" Name="dtime" PropertyName="SelectedDate"
                Type="DateTime" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
            <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                SortExpression="id" />
            <asp:BoundField DataField="dtime" HeaderText="dtime" SortExpression="dtime" />
        </Columns>
    </asp:GridView>
    <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>

If I attempt the same thing using RadControls, I get the following Error.

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.


Here is the code I am using for the same funtionallity above using RadControls:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
  
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadCalendar ID="RadCalendar1" Runat="server" AutoPostBack="True" 
        EnableMultiSelect="False" SelectedDate="" ViewSelectorText="x">
    </telerik:RadCalendar>
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" 
        GridLines="None">
<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
  
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
  
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumn DataField="DateSubNeeded" DataType="System.DateTime" 
            HeaderText="DateSubNeeded" SortExpression="DateSubNeeded" 
            UniqueName="DateSubNeeded">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Reason" HeaderText="Reason" 
            SortExpression="Reason" UniqueName="Reason">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="FullName" HeaderText="FullName" 
            ReadOnly="True" SortExpression="FullName" UniqueName="FullName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="EmailAddress" HeaderText="EmailAddress" 
            SortExpression="EmailAddress" UniqueName="EmailAddress">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Office" HeaderText="Office" 
            SortExpression="Office" UniqueName="Office">
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>
    </telerik:RadGrid>
    <p>
         </p>
    <p>
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
    </p>
    <p>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Human_ResourcesConnectionString %>" 
            SelectCommand="SELECT [DateSubNeeded], [Reason], [FullName], [EmailAddress], [Office] FROM [vw_SCS_SubRequests] WHERE ([DateSubNeeded] = @DateSubNeeded)">
            <SelectParameters>
                <asp:ControlParameter ControlID="RadCalendar1" Name="DateSubNeeded" 
                    PropertyName="SelectedDate" Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
    <p>
         </p>
    </form>
</body>
</html>


1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 07 Dec 2010, 10:06 AM
Hi Allan,

You can find a sample project attached to this post demonstrating that there is no problem using RadCalendar as a ControlParameter for a RadGrid bound to SqlDataSource. The problem is that you do not have neither a selected date for the calendar, nor a default value for the parameter.

Regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Calendar
Asked by
Allan
Top achievements
Rank 2
Answers by
Tsvetina
Telerik team
Share this question
or