是的,您可以在ASP.NET GridView中自定義分頁樣式。以下是一些建議的步驟來實現自定義分頁樣式:
<asp:GridView>標簽,然后在其中添加<PagerSettings>和<PagerTemplate>屬性。例如:<asp:GridView ID="GridView1" runat="server" AllowPaging="True">
<!-- 其他GridView設置 -->
<PagerSettings Mode="NextPreviousFirstLast" Position="Top" />
<PagerTemplate>
<div class="custom-pagination">
<!-- 在這里添加自定義分頁樣式 -->
</div>
</PagerTemplate>
</asp:GridView>
.custom-pagination {
display: flex;
justify-content: center;
list-style-type: none;
padding: 0;
}
.custom-pagination li {
margin: 0 5px;
}
.custom-pagination li a {
text-decoration: none;
color: #333;
padding: 5px 10px;
border: 1px solid #ccc;
background-color: #fff;
}
.custom-pagination li a:hover {
background-color: #f0f0f0;
}
.custom-pagination li a.active {
background-color: #007bff;
color: #fff;
border-color: #007bff;
}
PageIndexChanging事件處理程序。例如:protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindGridViewData(); // 重新綁定數據
}
現在,您的GridView應該具有自定義的分頁樣式。您可以根據需要調整CSS樣式以匹配您的網站設計。