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

asp.net ajax Blog Example

2 Answers 142 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
saquib
Top achievements
Rank 1
saquib asked on 18 Aug 2008, 04:58 AM
Hi, i like the RadAjax for ASP.NET AJAX Blog example and i create a page to display my blog on that. everything is perfectly work but i use sql server not access Db, so i'm getting error on SELECT * from BooksDB WHERE dtEntered = ? that 'Incorrect syntax near ? and i have 45 blog posts in my database so i want to retrieve by date with this method, and with this coding i'll retrieve my blog by selected dates only.

Public Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
        If e.Day.[Date] = DateTime.Parse("8/05/2008") OrElse e.Day.[Date] = DateTime.Parse("8/10/2008") OrElse e.Day.[Date] = DateTime.Parse("8/16/2008") Then
            e.Cell.Attributes.Add("class", "CalendarDay")
        Else
            e.Cell.Controls.Clear()
            e.Cell.Controls.Add(New LiteralControl(String.Format("<div>{0}</div>", e.Day.[Date].Day)))
        End If
End Sub

but i have 4 month of data, so i want to retrieve records according to this.

so please help me to solve this matter

thank you

2 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 18 Aug 2008, 07:34 AM
Hello saquib,

The parameters in SQL Select statements are marked with @YourFieldName. Here is an example:

SelectCommand="SELECT [OrderID], [OrderDate], [CustomerID], [ShipCountry] FROM [Orders] WHERE ([CustomerID] = @CustomerID)"

There are a lot of good SQL tutorials out there for example here and here.

You can also look at the RadGrid live demos for example, where the SQL statements are already implemented:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/SelectedValue/DefaultCS.aspx

Sincerely yours,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
saquib
Top achievements
Rank 1
answered on 18 Aug 2008, 08:13 AM
Hi, i can show you my code:
<%@ Page Language="VB" MasterPageFile="~/home.master" AutoEventWireup="false" CodeFile="myBlog.aspx.vb" Inherits="myBlog" title="Untitled Page" %> 
 
<%@ Register Assembly="DevExpress.Web.v7.3, Version=7.3.6.0, Culture=neutral, PublicKeyToken=49d90c14d24271b5" 
    Namespace="DevExpress.Web.ASPxDataView" TagPrefix="dxdv" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
<AjaxSettings> 
<telerik:AjaxSetting AjaxControlID="Calendar1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="BookGrid" LoadingPanelID="LoadingPanel1"></telerik:AjaxUpdatedControl> 
                        <telerik:AjaxUpdatedControl ControlID="Calendar1"></telerik:AjaxUpdatedControl> 
                    </UpdatedControls> 
 </telerik:AjaxSetting>                     
</AjaxSettings> 
</telerik:RadAjaxManager> 
<telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Height="75px" 
        Width="75px"
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' 
            style="border: 0px;" /> 
</telerik:RadAjaxLoadingPanel> 
<div class="blogBorders"
            <div class="blogContentWrapper"
                <div class="header"
                </div> 
                <div class="calendar"
                    <div class="calendarWrapper"
<asp:Calendar ID="Calendar1" runat="server" BorderStyle="None" CellPadding="0" CssClass="aspCalendar" 
DayNameFormat="FirstLetter" VisibleDate="08/05/2008" CellSpacing="0" OnDayRender="Calendar1_DayRender" 
OnSelectionChanged="Calendar1_SelectionChanged"
<DayHeaderStyle BackColor="White"></DayHeaderStyle> 
                            <TitleStyle ForeColor="White" CssClass="title" BackColor="Transparent" Wrap="False"
                            </TitleStyle> 
                        </asp:Calendar> 
</div> 
                </div> 
<div id="BlogPostPlaceHolder"
<dxdv:ASPxDataView ID="BookGrid" runat="server" DataSourceID="BookSource" 
RowPerPage="4" AlwaysShowPager="True" ColumnCount="2"
<ItemTemplate> 
<div style="height: 100px;"><asp:Image ID="Image1" Width="100" Height="100" Runat="Server" 
        AlternateText='<%# "Picture of " & Eval("image") %>' 
        ImageUrl='<%# "images/" & Eval("image") & ".jpg"  %>' /></div
<br /><br /> 
<div class="DataViewItemTitle"><asp:HyperLink ID="HyperLink2" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"CategoryTitle") %>' NavigateUrl='<%# "Details.aspx?CategoryID=" & Container.DataItem("CategoryID")  %>' /></div
</ItemTemplate> 
<PagerSettings SEOFriendly="Enabled"
          <AllButton Visible="True"
          </AllButton> 
</PagerSettings> 
    <ItemStyle HorizontalAlign="Center"
        <BackgroundImage HorizontalPosition="center" ImageUrl="~/images/diag_gris.gif" /> 
    </ItemStyle> 
    <PagerStyle BackColor="#FF8080"
        <BackgroundImage HorizontalPosition="center" /> 
    </PagerStyle> 
</dxdv:ASPxDataView>    
</div> 
            </div> 
        </div> 
<asp:SqlDataSource ID="BookSource" runat="server" ConnectionString="<%$ ConnectionStrings:SecurityTutorialsConnectionString %>" SelectCommand="select * from BooksDB WHERE dtEntered = @dtEntered"
<SelectParameters> 
<asp:ControlParameter ControlID="Calendar1" DefaultValue="08/05/2008" Name="dtEntered" 
PropertyName="SelectedDate" Type="DateTime" /> 
</SelectParameters> 
</asp:SqlDataSource>                                                                    
</asp:Content> 
 
 

and vb code:
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
        If Not Page.IsPostBack Then 
            Calendar1.SelectedDate = DateTime.Parse("08/05/2008"
        End If 
    End Sub 
 
    Public Sub Calendar1_DayRender(ByVal sender As ObjectByVal e As DayRenderEventArgs) 
        If e.Day.[Date] = DateTime.Parse("08/05/2008"OrElse e.Day.[Date] = DateTime.Parse("08/10/2008"OrElse e.Day.[Date] = DateTime.Parse("08/16/2008"Then 
            e.Cell.Attributes.Add("class""CalendarDay"
        Else 
            e.Cell.Controls.Clear() 
            e.Cell.Controls.Add(New LiteralControl(String.Format("<div>{0}</div>", e.Day.[Date].Day))) 
        End If 
    End Sub 
 
    Public Sub Calendar1_SelectionChanged(ByVal sender As ObjectByVal e As EventArgs) 
        System.Threading.Thread.Sleep(2000) 
    End Sub 

i used the method that u specify but my devexpress dataview grid not display. if i type select * from booksdb. it display the the dataview but not work with calender control.

thank you

saquib
Tags
Ajax
Asked by
saquib
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
saquib
Top achievements
Rank 1
Share this question
or