PagerSettings.Mode Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur mode untuk menampilkan kontrol pager dalam kontrol yang mendukung penomoran halaman.
public:
property System::Web::UI::WebControls::PagerButtons Mode { System::Web::UI::WebControls::PagerButtons get(); void set(System::Web::UI::WebControls::PagerButtons value); };
public System.Web.UI.WebControls.PagerButtons Mode { get; set; }
member this.Mode : System.Web.UI.WebControls.PagerButtons with get, set
Public Property Mode As PagerButtons
Nilai Properti
Salah PagerButtons satu nilai. Defaultnya adalah PagerButtons.Numeric.
Pengecualian
Mode diatur ke nilai yang bukan salah PagerButtons satu nilai.
Contoh
Contoh kode berikut menunjukkan cara menggunakan Mode properti untuk menentukan bahwa baris pager untuk GridView kontrol harus menampilkan tombol numerik.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>PagerSetting Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PagerSetting Example</h3>
<asp:gridview id="CustomerGridView"
datasourceid="CustomerDataSource"
autogeneratecolumns="true"
datakeynames="CustomerID"
allowpaging="true"
runat="server">
<pagersettings mode="NumericFirstLast"
firstpagetext="First"
lastpagetext="Last"
pagebuttoncount="5"
position="Bottom"/>
</asp:gridview>
<br/>
<asp:label id="MessageLabel"
forecolor="Red"
runat="server"/>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomerDataSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>PagerSetting Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>PagerSetting Example</h3>
<asp:gridview id="CustomerGridView"
datasourceid="CustomerDataSource"
autogeneratecolumns="true"
datakeynames="CustomerID"
allowpaging="true"
runat="server">
<pagersettings mode="NumericFirstLast"
firstpagetext="First"
lastpagetext="Last"
pagebuttoncount="5"
position="Bottom"/>
</asp:gridview>
<br/>
<asp:label id="MessageLabel"
forecolor="Red"
runat="server"/>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomerDataSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
Keterangan
Kontrol yang mendukung penomoran halaman menyediakan beberapa mode untuk menampilkan kontrol penomoran halaman. Mode Gunakan properti untuk menentukan mode. Tabel berikut ini menjelaskan berbagai mode untuk kontrol penomoran halaman.
| Modus | Deskripsi |
|---|---|
| NextPrevious | Tombol halaman sebelumnya dan halaman berikutnya. |
| NextPreviousFirstLast | Tombol halaman sebelumnya, halaman berikutnya, halaman pertama, dan halaman terakhir. |
| Numeric | Tombol tautan bernomor untuk mengakses halaman secara langsung. |
| NumericFirstLast | Tombol bernomor dan tautan pertama dan tautan terakhir. |
Mode Saat properti diatur ke NextPreviousnilai , , NextPreviousFirstLastatau NumericFirstLast , Anda dapat menentukan teks kustom untuk tombol non-numerik dengan mengatur properti yang diperlihatkan dalam tabel berikut.
| Harta benda | Deskripsi |
|---|---|
| FirstPageText | Teks untuk tombol halaman pertama. |
| PreviousPageText | Teks untuk tombol halaman sebelumnya. |
| NextPageText | Teks untuk tombol halaman berikutnya. |
| LastPageText | Teks untuk tombol halaman terakhir. |
Sebagai alternatif, Anda juga dapat menampilkan gambar untuk tombol non-numerik dengan mengatur properti yang diperlihatkan dalam tabel berikut.
| Harta benda | Deskripsi |
|---|---|
| FirstPageImageUrl | URL ke gambar yang akan ditampilkan untuk tombol halaman pertama. |
| PreviousPageImageUrl | URL ke gambar yang akan ditampilkan untuk tombol halaman sebelumnya. |
| NextPageImageUrl | URL ke gambar yang akan ditampilkan untuk tombol halaman berikutnya. |
| LastPageImageUrl | URL ke gambar yang akan ditampilkan untuk tombol halaman terakhir. |
Nota
Saat properti gambar diatur, properti teks yang sesuai bertindak sebagai teks alternatif untuk gambar. Misalnya, saat FirstPageImageUrl properti diatur, teks yang ditentukan oleh FirstPageText properti ditampilkan sebagai teks alternatif untuk gambar. Pada browser yang mendukung TipsAlat, teks ini juga ditampilkan sebagai TipsAlat untuk tombol yang sesuai.
Nilai properti ini disimpan dalam status tampilan.