Step by step. NET three-layer architecture Analysis 8. UI design (the design of the GridView and its paging)

Source: Internet
Author: User

This time, we designed the employee operation list Custom. aspx and department operation list Departmant. aspx, and how to design the pagination function of the GridView.

Call the BLL design method to obtain the List of data, convert it to PagedDataSource, and set the PagedDataSource attribute to implement the paging function.

First look at the design of Custom. aspx:

View sourceprint? <Div style = "text-align: center">

<Asp: GridView ID = "gvCustom" DataKeyNames = "ID"

OnRowDeleting = "GridView_RowDeleting" runat = "server" CellPadding = "4"

ForeColor = "#333333" GridLines = "None" HorizontalAlign = "Center" Width = "98%"

CellSpacing = "1" AutoGenerateColumns = "False">

<FooterStyle BackColor = "#507CD1" Font-Bold = "True" ForeColor = "White"/>

<RowStyle BackColor = "# EFF3FB" HorizontalAlign = "Center"/>

<EditRowStyle BackColor = "# 2461BF" Font-Italic = "True" HorizontalAlign = "Center" VerticalAlign = "Middle"/>

<SelectedRowStyle BackColor = "# D1DDF1" Font-Bold = "True" ForeColor = "#333333"/>

<PagerStyle BackColor = "# 2461BF" ForeColor = "White" HorizontalAlign = "Center"/>

<HeaderStyle BackColor = "Silver" Font-Bold = "True" ForeColor = "White" Font-Size = "12px" HorizontalAlign = "Center"/>

<AlternatingRowStyle BackColor = "White"/>

<Columns>

<Asp: BoundField DataField = "id" HeaderText = "ID"/>

<Asp: BoundField DataField = "ename" HeaderText = "account name"/>

<Asp: BoundField DataField = "cname" HeaderText = "name"/>

<Asp: BoundField DataField = "age" HeaderText = "age"/>

<Asp: BoundField DataField = "canonical name" HeaderText = "department"/>

<Asp: HyperLinkField DataTextField = "id" DataTextFormatString = "modify"

HeaderText = "modify" DataNavigateUrlFields = "id" DataNavigateUrlFormatString = "Updatecustom. aspx? Id = {0} "/>

<Asp: TemplateField HeaderText = "delete">

<ItemTemplate>

<Asp: LinkButton ID = "LinkButton2" OnClientClick = "return confirm (Are you sure you want to delete this record ?); "Runat =" server "CommandName =" Delete "Font-Names =" "Font-Strikeout =" False "Font-Underline =" False "ForeColor =" Black "> Delete </asp: linkButton>

</ItemTemplate>

</Asp: TemplateField>

</Columns>

</Asp: GridView>

<Asp: Button ID = "btnAddUser" runat = "server" onclick = "btnAddUser_Click"

Text = "Add User"/>

Current page number: <asp: Label ID = "labPage" runat = "server" Text = "1"> </asp: Label>

Total page number: <asp: Label ID = "labBackPage" runat = "server"> </asp: Label>

<Asp: LinkButton ID = "lnkbtnOne" runat = "server" OnClick = "lnkbtnOne_Click"> page 1 </asp: LinkButton>

<Asp: LinkButton ID = "lnkbtnUp" runat = "server" OnClick = "lnkbtnUp_Click"> previous page </asp: LinkButton>

<Asp: LinkButton ID = "lnkbtnNext" runat = "server" OnClick = "lnkbtnNext_Click"> next page </asp: LinkButton>

<Asp: LinkButton ID = "lnkbtnBack" runat = "server" OnClick = "lnkbtnBack_Click"> last page </asp: LinkButton>

</Div>

Now let's take a look at the design of Custom. aspx. cs:

Note:

View sourceprint? Using BLL;

Using Model;

Then:

View sourceprint? Public partial class Custom: PageBase

{

Protected void Page_Load (object sender, EventArgs e)

{

If (! Page. IsPostBack)

{

// Verify the permission

IsAdmin ();

BinData ();

}

}

/// <Summary>

/// Bind data

/// </Summary>

Private void BinData ()

{

CustomSystem CustomSystem = new customSystem ();

List <custom> Customlist = new List <custom> ();

// Call The BLL method to obtain the list

Customlist = CustomSystem. GetCustom ();

Int curpage = Convert. ToInt32 (this. labPage. Text );

// Design page

PagedDataSource ps = new PagedDataSource ();

Ps. DataSource = Customlist;

Ps. AllowPaging = true;

// Set the number of entries on the page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.