开发者

end of statement expected

Imports System
Imports System.IO
Imports System.Linq

Namespace PhotoGalleryApp
    Partial Public Class Index
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Path to photos folder
            Dim photosRelativePath = "~/photos/"
            Dim photosFilePath = Me.Server.MapPath(photosRelativePath)

           ' Get list of img files from photos folder
            Dim photos = From file In New DirectoryInf(photosFilePath).GetFiles() 
            Where (file.Name.EndsWith(".jpg",
                                StringComparison.InvariantCultureIgnoreCase)
                   OrElse file.Name.EndsWith(".gif",
                                StringComparison.InvariantCultureIgnoreCase)
                   OrElse file.Name.EndsWith(".png",
                                StringComparison.InvariantCultureIgnoreCase))
            Select photosRelativePath & file.Name

            ' Return photos as string array
            lstPhotos.DataSource = photos.ToArray()
            lstPhotos.DataBind()
        End Sub
    End Class
End Namespace

I am using this code for jQuery Cycle Plugin.

This is the aspx code

 <asp:ListView ID="lstPhotos" runat="server">
        <ItemTemplate>
            <img src='<%# ResolveUrl(Container.DataItem.ToString()) %>' width="250" height="300" />
        </ItemTemplate>
        </asp:ListView>


    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js"></script> 
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.cycle/2.88/jquery.cycle.all.js"></script> 
    <script type="text/javascript">

        $("#photos").cycle("toss");

    </script> 

I am setting the Dat开发者_StackOverflow社区aSource of the LIstView as Photos.ToArray() in the code behind..but still i get the error.. "Select DataSource for ListView"


Try replacing

Dim photos = From file In New DirectoryInfo(photosFilePath).GetFiles() 
                Where (file.Name.EndsWith(".jpg", 
                             StringComparison.InvariantCultureIgnoreCase) 
                           OrElse 
                       file.Name.EndsWith(".gif", 
                             StringComparison.InvariantCultureIgnoreCase) OrElse 
                       file.Name.EndsWith(".png", 
                             StringComparison.InvariantCultureIgnoreCase)) 
                       photosRelativePath & file.Name

with

Dim photos = From file In New DirectoryInfo(photosFilePath).GetFiles() 
                Where (file.Name.EndsWith(".jpg", 
                             StringComparison.InvariantCultureIgnoreCase) OrElse
                       file.Name.EndsWith(".gif", 
                             StringComparison.InvariantCultureIgnoreCase) OrElse 
                       file.Name.EndsWith(".png", 
                             StringComparison.InvariantCultureIgnoreCase)) 
                       select photosRelativePath & file.Name
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜