熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

7.4.3 DataList和Repeater控件[3]

2013-11-13 12:17:08  來源: .NET編程 

    ()現在對DataList進行一些修改回到Design View修改DataList控件的布局選中這個DataLxst控件在Properties窗口中將RepeatColumns修改為將RepeatDirection修改為Horizontal

    ()進行一點修改在Design View中選擇該DataList控件並打開它的智能任務面板單擊Edit Templates默認情況下您將修改Item模板

    ()刪除文本Notes:但保留顯示注釋的標簽

    ()在模板中將FixtureID的位置向上移動而將Member Name向下移動在UploadedByMemberName文本之間添加一些空格使其更容易閱讀刪除表示PictureURL的文本和標簽

    ()在DataList控件的智能任務面板中(可能還沒有打開)單擊End Template Editing該頁面Source View中將如下所示

 

<%@ Page Language=VB MasterPageFile=~/sitemaster AutoEventWireup=false CodeFile=GalleryAllaspxvb Inherits=Gallery_AllTest title=Untitled Page %>

<asp:Content ID=Content ContentPlaceHolderID=mainContent Runat=Server>

        <asp:DataList ID=DataList runat=server DataSourceID=SqlDataSource RepeatColumns= RepeatDirection=Horizontal>

     <ItemTemplate>

        

            <asp:Image ID=Image runat=server ImageUrl=<%#

         ~/MatchImages/() %>/><br />

               

            <asp:Label ID=NotesLabel runat=server Text=<%#

         Eval(Notes)

                             %>></asp:Label><br />

 

            FixtureID:

            <asp:Label ID=FixtureIDLabel runat=server Text=<%#

          Eval(FixtureID) %>></asp:Label><br />

          

           Uploaded By Member:

            <asp:Label ID=UploadedByMemberNameLabel runat=server

            Text=<%#

                    Eval(UploadedByMemberName) %>></asp:Label><br />

        </ItemTemplate>

    </asp:DataList>

   

    <asp:SqlDataSource ID=SqlDataSource runat=server

        ConnectionString=<%$ ConnectionStrings:WroxUnited%>

        SelectCommand=SELECT [PictureURL] [Notes] [UploadedByMemberName] [FixtureID]

        FROM [Gallery]>

     

    </asp:SqlDataSource>

</asp:Content>

    ()運行該頁面以便在浏覽器中查看工作的結果

[]  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/15578.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.