ImageField.DataImageUrlField 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定資料來源中的欄位名稱,這個欄位的值將繫結至 ImageUrl 物件中每個影像的 ImageField 屬性。
public:
virtual property System::String ^ DataImageUrlField { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public virtual string DataImageUrlField { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public virtual string DataImageUrlField { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.DataImageUrlField : string with get, set
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.DataImageUrlField : string with get, set
Public Overridable Property DataImageUrlField As String
屬性值
欄位名稱,這個欄位將繫結至 ImageUrl 物件中每個影像的 ImageField 屬性。
- 屬性
範例
下列範例程式碼示範如何使用 DataImageUrlField 屬性來指定功能變數名稱,以系結至 ImageUrl 物件中 ImageField 每個影像的屬性。
<%@ 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>ImageField Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ImageField Example</h3>
<asp:gridview id="EmployeesGrid"
autogeneratecolumns="false"
datasourceid="EmployeeSource"
runat="server">
<columns>
<asp:imagefield dataimageurlfield="LastName"
dataimageurlformatstring="~\Images\{0}.jpg"
alternatetext="Employee Photo"
nulldisplaytext="No image on file."
headertext="Photo"
readonly="true"/>
<asp:boundfield datafield="FirstName"
headertext="First Name"/>
<asp:boundfield datafield="LastName"
headertext="Last Name"/>
</columns>
</asp:gridview>
<!-- 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="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName] From [Employees]"
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>ImageField Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ImageField Example</h3>
<asp:gridview id="EmployeesGrid"
autogeneratecolumns="false"
datasourceid="EmployeeSource"
runat="server">
<columns>
<asp:imagefield dataimageurlfield="LastName"
dataimageurlformatstring="~\Images\{0}.jpg"
alternatetext="Employee Photo"
nulldisplaytext="No image on file."
headertext="Photo"
readonly="true"/>
<asp:boundfield datafield="FirstName"
headertext="First Name"/>
<asp:boundfield datafield="LastName"
headertext="Last Name"/>
</columns>
</asp:gridview>
<!-- 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="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName] From [Employees]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
備註
DataImageUrlField使用 屬性來指定要系結至 ImageUrl 物件中 ImageField 每個影像之屬性的功能變數名稱。 指定的欄位必須包含要顯示在 物件中的 ImageField 影像 URL。 您可以藉由設定 DataImageUrlFormatString 屬性,選擇性地格式化 URL 值。
注意
當欄位值為 null
時,無法顯示影像。 您可以藉由設定 NullImageUrl 屬性來顯示域值的替代影像 null
。 您可以藉由設定 NullDisplayText 屬性來顯示替代文字,而不是替代影像。