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 :)