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

7.4.4 DetaiIsView和FormView控件[2]

2022-06-13   來源: .NET編程 

    結果如下代碼所示

 

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

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

    <asp:DetailsView ID=DetailsView runat=server AllowPaging=True AutoGenerateRows=False

        DataKeyNames=FixtureID DataSourceID=SqlDataSource Height=px Width=px>

        <PagerSettings FirstPageText=First Game of the Season LastPageText=Last Game of the Season

            Mode=NumericFirstLast />

        <Fields>

            <asp:BoundField DataField=FixtureID HeaderText=FixtureID InsertVisible=False

                ReadOnly=True SortExpression=FixtureID />

            <asp:BoundField DataField=FixtureDate HeaderText=FixtureDate SortExpression=FixtureDate />

            <asp:BoundField DataField=FixtureType HeaderText=FixtureType SortExpression=FixtureType />

            <asp:BoundField DataField=GoalsFor HeaderText=GoalsFor SortExpression=GoalsFor />

            <asp:BoundField DataField=GoalsAgainst HeaderText=GoalsAgainst SortExpression=GoalsAgainst />

            <asp:BoundField DataField=Notes HeaderText=Notes SortExpression=Notes />

            <asp:BoundField DataField=Opponents HeaderText=Opponents SortExpression=Opponents />

        </Fields>

    </asp:DetailsView>

    <asp:SqlDataSource ID=SqlDataSource runat=server ConnectionString=<%$ ConnectionStrings:WroxUnitedConnectionString %>

        SelectCommand=SELECT * FROM [Fixtures]></asp:SqlDataSource>

</asp:Content>

    ()在浏覽器中運行該頁面以觀察每次只顯示一場比賽

    操作回顧

    這個練習的關鍵是創建和查看每次只顯示一條記錄的頁面就像查看一疊卡片中最上面的那一張可以使用DetailsView或FormView選擇Detai is View是因為它有一個自動的默認布局

    對DetailsView控件所做的修改與在前面的練習中對其他數據綁定控件所做的修改幾乎是一樣的為了在比賽的記錄之間移動可以通過勾選該控件的智能任務面板中恰當的復選框激活分頁功能為了增強用戶的體驗可以在該控件的Properties窗口中指定了一組特定的導航工具並修改它們的文本以便提供一個更加符合邏輯的用戶界面

    ASPNET 入門教程完整版

[]  []  


From:http://tw.wingwit.com/Article/program/net/201311/15414.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.