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

ASP.NET項目開發指南:房間信息管理頁面(1)

2013-11-13 12:28:23  來源: .NET編程 

    房間信息管理頁面(

  在管理員界面中單擊房間信息管理超鏈接將進入房間信息管理頁面ST_RoomsManaspx如圖所示

  房間信息管理頁面

  ST_RoomsManaspx的HTML代碼

  頁面整體與前面基本相同這裡不再贅述下面來看控件<Module:RoomsMan id=ModuleRoomsMan runat=server />ST_RoomsManModuleascx的HTML代碼如程序所示

  程序  ST_RoomsManModuleascx

    <TABLE cellSpacing= cellPadding= width=%>

        <TR class=rheader>

            <TD class=rheadercol align=left colSpan= height=>

                房間信息管理

            </TD>

        </TR> <! SPACER ROW >

        <TR class=rbody>

            <TD class=rbodycol align=left width=% height=

        colspan=>按房間號<asp:textbox id=RoomIdTextBox Width=px

        runat=server></asp:textbox>

                <asp:button id=search BorderStyle=Groove

                runat=server Text=查詢></asp:button></TD>

        </TR>

        <TR class=rbody>

            <TD class=rbodycol align=center colSpan= height=>

                    <!GridView控件>

            <asp:GridView id=dg_RoomsList

            onpageindexchanging =DataGrid_Page

            onrowdeleting =DataGrid_Delete

            DataKeyNames=ST_RoomId BorderColor=Black

            AutoGenerateColumns=False PageSize= Width=%

            AllowPaging=True runat=server>

            <AlternatingRowStyle

                BackColor=#CCCCFF></AlternatingRowStyle>

            <HeaderStyle FontBold=True

                BackColor=#CCCCFF></HeaderStyle>

            <Columns>

                <asp:BoundField DataField=ST_RoomId SortExpression=

                    HeaderText=房間號></asp:BoundField>

                <asp:BoundField DataField=ST_Name HeaderText=房間類型>

                    </asp:BoundField>

                <asp:BoundField DataField=ST_Price

                    HeaderText=價格(元/天)></asp:BoundField>

                <asp:BoundField DataField=ST_RPosition

                    HeaderText=房間位置></asp:BoundField>

                <asp:HyperLinkFiled DataNavigateUrlFields=ST_RoomId

                DataNavigateUrlFormatString=

                    /ST_RoomEditaspx?RoomId={}

                    DataTextField=ST_RoomId HeaderText=修改

                    DataTextFormatString=詳單></asp:HyperLinkFiled>

                <asp:ButtonField Text=刪除 HeaderText=刪除

                    CommandName=Delete

                    ButtonType=Button></asp:ButtonField>

            </Columns>

            <PagerSettings NextPageText=下一頁

                Mode=NextPrevious PreviousPageText=上一頁 />

            </asp:GridView>

        </TD>

        </TR>

        <TR>

            <td width=% height=><a id=AddRoomLink

        href=<%=ST_PageBaseUrlBase + /ST_RoomAddaspx%>>添加新房間</a>

            </td>

            <TD align=right><asp:button id=ShowAll runat=server

                Text=全部顯示 BorderStyle=Groove

            Visible=False></asp:button></TD>

        </TR>

    </TABLE>

  【代碼說明】代碼第~行是一個GridView控件其中包含個綁定列如代碼第行通過DataField屬性綁定了ST_RoomId字段代碼第行非常關鍵通過DataKeyNames屬性指定當前數據的主鍵這個主鍵直接影響到數據的刪除和修訂是否成功代碼第~行說明GridView進行了分頁設計要分頁必須如代碼第行一樣將AllowPaging屬性設置為True

       返回目錄ASPNET項目開發指南

       編輯推薦

       ASPNET MVC 框架揭秘

       ASPNET開發寶典

       ASP NET開發培訓視頻教程


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