FormView.EmptyDataRowStyle 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 referensi ke TableItemStyle objek yang memungkinkan Anda mengatur tampilan baris data kosong yang ditampilkan saat sumber data yang FormView terikat ke kontrol tidak berisi rekaman apa pun.
public:
property System::Web::UI::WebControls::TableItemStyle ^ EmptyDataRowStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle EmptyDataRowStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.EmptyDataRowStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property EmptyDataRowStyle As TableItemStyle
Nilai Properti
Referensi ke TableItemStyle yang memungkinkan Anda mengatur tampilan baris data kosong.
- Atribut
Contoh
Contoh berikut menunjukkan cara menggunakan EmptyDataRowStyle properti untuk menentukan gaya kustom untuk baris data kosong yang ditampilkan saat FormView kontrol terikat ke sumber data yang tidak berisi rekaman apa pun.
<%@ 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>FormView EmptyDataText Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>FormView EmptyDataText Example</h3>
<asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
emptydatatext="No records available."
runat="server">
<EmptyDataRowStyle BackColor="Red"
forecolor="White"
font-size="14"
font-italic="true"
height="100"/>
<itemtemplate>
<table>
<tr>
<td>
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td>
<h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>
<%# Eval("Title") %>
</td>
</tr>
</table>
</itemtemplate>
<pagersettings position="Bottom"
mode="NextPrevious"/>
</asp:formview>
<!-- 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. -->
<!-- The select query for the following SqlDataSource -->
<!-- control is intentionally set to return no results -->
<!-- to demonstrate the empty data row. -->
<asp:sqldatasource id="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees] Where [EmployeeID]=1000"
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>FormView EmptyDataText Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>FormView EmptyDataText Example</h3>
<asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
emptydatatext="No records available."
runat="server">
<EmptyDataRowStyle BackColor="Red"
forecolor="White"
font-size="14"
font-italic="true"
height="100"/>
<itemtemplate>
<table>
<tr>
<td>
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td>
<h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3>
<%# Eval("Title") %>
</td>
</tr>
</table>
</itemtemplate>
<pagersettings position="Bottom"
mode="NextPrevious"/>
</asp:formview>
<!-- 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. -->
<!-- The select query for the following SqlDataSource -->
<!-- control is intentionally set to return no results -->
<!-- to demonstrate the empty data row. -->
<asp:sqldatasource id="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees] Where [EmployeeID]=1000"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
Keterangan
EmptyDataRowStyle Gunakan properti untuk mengontrol tampilan baris data kosong dalam FormView kontrol. Baris data kosong ditampilkan saat sumber data yang terikat ke kontrol tidak berisi rekaman apa pun. Properti ini bersifat baca-saja; namun, Anda dapat mengatur properti objek yang TableItemStyle dikembalikannya. Properti dapat diatur secara deklaratif menggunakan salah satu metode berikut:
Tempatkan atribut di tag FormView pembuka kontrol dalam formulir
Property-Subproperty
, di manaSubproperty
adalah properti TableItemStyle objek (misalnya,EmptyDataRowStyle-ForeColor
).Sarangkan
<EmptyDataRowStyle>
elemen antara tag FormView pembuka dan penutup kontrol.
Properti juga dapat diatur secara terprogram dalam formulir Property.Subproperty
(misalnya, EmptyDataRowStyle.ForeColor
). Pengaturan umum biasanya mencakup warna latar belakang kustom, warna latar depan, dan properti font.