Close access to ASP. Net (12)

Source: Internet
Author: User

Page of the DataGrid (2)
Next I will talk about the page of the DataGrid in the previous section. In the preceding example, we can see that for paging control
It's enough, huh, huh, but it's just a normal page. It's boring. Let's just change it. First
Describes the properties used by the DataGrid Control in the previous section.
<ASP: DataGrid id = "DataGrid1" runat = "server"
AllowPaging = "True"
PageSize = "5"
PagerStyle-HorizontalAlign = "Right"
BorderColor = "black"
BorderWidth = "1"
GridLines = "Both"
CellPadding = "3"
CellSpacing = "0"
Font-Name = "Verdana"
Font-Size = "8pt"
HeaderStyle-BackColor = "# aaaadd"
AlternatingItemStyle-BackColor = "# eeeeee"
/>
Some of them will not be able to understand its attributes. Here are a few fresh ones :)
HeaderStyle-BackColor indicates the color of the Column.
AlternatingItemStyle-BackColor indicates the color that appears alternately across rows.
We have seen these in the previous section. Next I will talk about some attributes.
We looked at the "<" and ">" not pleasing to the eye. We wanted to change them to "Previous Page" and "next page". It was very easy to add
Attributes
PagerStyle-NextPageText = "next page"
PagerStyle-PrevPageText = "Previous Page"
Let's take a look:
Figure 12-1
How about it? Changed it :)
We are still not familiar with it. It would be nice to mark it with numbers 123. Also. Add attributes.
PagerStyle-Mode = "NumericPages"
Let's take a look:
Figure 12-2
Done.
If you can display the total number of pages and report the current number of pages, that would be nice :).
It is not possible to change the attribute. We add the following code
Current page: <font color = red> <% = DataGrid1.CurrentPageIndex + 1%> </font> <br>
Total number of pages: <font color = red> <% = DataGrid1.PageCount %> </font> <br>
Let's look at it again:
Is it OK again. Some friends still need to add the "Last page" and "Homepage" links. This is also possible,
But it is much more complicated.
It's too late. Let's talk about it next time. It mainly uses the OnPageIndexChanged event. Haha, interested friends
You can do it first :)

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.