HyperLinkField.DataTextField 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
HyperLinkField 개체의 하이퍼링크 캡션에 대해 표시할 텍스트를 포함하는 데이터 소스의 필드 이름을 가져오거나 설정합니다.
public:
virtual property System::String ^ DataTextField { 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 DataTextField { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public virtual string DataTextField { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.DataTextField : 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.DataTextField : string with get, set
Public Overridable Property DataTextField As String
속성 값
HyperLinkField의 하이퍼링크 캡션에 대해 표시할 값을 포함하는 데이터 소스의 필드 이름입니다. 기본값은 빈 문자열("")로, 이 속성이 설정되어 있지 않음을 나타냅니다.
- 특성
예제
다음 코드 예제를 사용 하는 방법에 설명 합니다 DataTextField 에 표시 되는 하이퍼링크 캡션에 바인딩할 데이터 소스의 필드를 지정 하는 속성을 HyperLinkField 개체.
<%@ 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>HyperLinkField DataBinding Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HyperLinkField DataBinding Example</h3>
<!-- Populate the Columns collection declaratively. -->
<!-- Bind the CompanyName and HomePage fields from the -->
<!-- Northwind database to the caption and URL of the -->
<!-- hyperlinks in the HyperLinkField field column. Note -->
<!-- that the URLs specified in the Northwind database -->
<!-- might not be valid URLs. -->
<asp:gridview id="SuppliersGridView"
datasourceid="SuppliersSqlDataSource"
autogeneratecolumns="false"
runat="server">
<columns>
<asp:hyperlinkfield datatextfield="CompanyName"
datanavigateurlfields="HomePage"
headertext="Company Name"
target="_blank" />
<asp:boundfield datafield="City"
headertext="City"/>
</columns>
</asp:gridview>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. -->
<asp:sqldatasource id="SuppliersSqlDataSource"
selectcommand="SELECT [SupplierID], [CompanyName], [City], [HomePage] FROM [Suppliers]"
connectionstring="server=localhost;database=northwind;integrated security=SSPI"
runat="server">
</asp:sqldatasource>
</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>HyperLinkField DataBinding Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HyperLinkField DataBinding Example</h3>
<!-- Populate the Columns collection declaratively. -->
<!-- Bind the CompanyName and HomePage fields from the -->
<!-- Northwind database to the caption and URL of the -->
<!-- hyperlinks in the HyperLinkField field column. Note -->
<!-- that the URLs specified in the Northwind database -->
<!-- might not be valid URLs. -->
<asp:gridview id="SuppliersGridView"
datasourceid="SuppliersSqlDataSource"
autogeneratecolumns="false"
runat="server">
<columns>
<asp:hyperlinkfield datatextfield="CompanyName"
datanavigateurlfields="HomePage"
headertext="Company Name"
target="_blank" />
<asp:boundfield datafield="City"
headertext="City"/>
</columns>
</asp:gridview>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. -->
<asp:sqldatasource id="SuppliersSqlDataSource"
selectcommand="SELECT [SupplierID], [CompanyName], [City], [HomePage] FROM [Suppliers]"
connectionstring="server=localhost;database=northwind;integrated security=SSPI"
runat="server">
</asp:sqldatasource>
</form>
</body>
</html>
다음 코드 예제를 사용 하는 방법에 설명 합니다 DataTextFormatString 값의 형식을 지정 하는 속성에 표시 되는 하이퍼링크 캡션에 바인딩할를 HyperLinkField 개체입니다. 값의 서식이 통화로 지정 됩니다.
<%@ 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>HyperLinkField Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HyperLinkField Example</h3>
<!-- Populate the Columns collection declaratively. -->
<!-- The UnitPrice field values are bound to the -->
<!-- captions of the hyperlinks in the HyperLinkField -->
<!-- field column, formatted as currency. The ProductID -->
<!-- field values are bound to the navigate URLs of the -->
<!-- hyperlinks. However, instead of being the actual -->
<!-- URL values, the product ID is passed to the linked -->
<!-- page as a parameter in the URL specified by the -->
<!-- DataNavigateUrlFormatString property. -->
<asp:gridview id="OrdersGridView"
datasourceid="OrdersSqlDataSource"
autogeneratecolumns="false"
runat="server">
<columns>
<asp:boundfield datafield="OrderID"
headertext="Order ID"/>
<asp:boundfield datafield="ProductID"
headertext="Product ID"/>
<asp:hyperlinkfield datatextfield="UnitPrice"
datatextformatstring="{0:c}"
datanavigateurlfields="ProductID"
datanavigateurlformatstring="~\details.aspx?ProductID={0}"
headertext="Price"
target="_blank" />
<asp:boundfield datafield="Quantity"
headertext="Quantity"/>
</columns>
</asp:gridview>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. -->
<asp:sqldatasource id="OrdersSqlDataSource"
selectcommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity] FROM [Order Details]"
connectionstring="server=localhost;database=northwind;integrated security=SSPI"
runat="server">
</asp:sqldatasource>
</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>HyperLinkField DataTextFormatString and DataNavigateUrlFormatString Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HyperLinkField DataTextFormatString and DataNavigateUrlFormatString Example</h3>
<!-- Populate the Columns collection declaratively. -->
<!-- The UnitPrice field values are bound to the -->
<!-- captions of the hyperlinks in the HyperLinkField -->
<!-- field column, formatted as currency. The ProductID -->
<!-- field values are bound to the navigate URLs of the -->
<!-- hyperlinks. However, instead of being the actual -->
<!-- URL values, the product ID is passed to the linked -->
<!-- page as a parameter in the URL specified by the -->
<!-- DataNavigateUrlFormatString property. -->
<asp:gridview id="OrdersGridView"
datasourceid="OrdersSqlDataSource"
autogeneratecolumns="false"
runat="server">
<columns>
<asp:boundfield datafield="OrderID"
headertext="Order ID"/>
<asp:boundfield datafield="ProductID"
headertext="Product ID"/>
<asp:hyperlinkfield datatextfield="UnitPrice"
datatextformatstring="{0:c}"
datanavigateurlfields="ProductID"
datanavigateurlformatstring="~\details.aspx?ProductID={0}"
headertext="Price"
target="_blank" />
<asp:boundfield datafield="Quantity"
headertext="Quantity"/>
</columns>
</asp:gridview>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. -->
<asp:sqldatasource id="OrdersSqlDataSource"
selectcommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity] FROM [Order Details]"
connectionstring="server=localhost;database=northwind;integrated security=SSPI"
runat="server">
</asp:sqldatasource>
</form>
</body>
</html>
설명
사용 된 DataTextField 속성의 하이퍼링크 캡션에 대해 표시할 텍스트를 포함 하는 필드의 이름을 지정 하는 HyperLinkField 개체.
이 속성을 사용 하 여 필드에 하이퍼링크 캡션에 바인딩할를 대신 사용할 수 있습니다는 Text 하이퍼링크 캡션에 정적 값으로 설정 하는 속성입니다. 이 옵션을 사용 하 여 각 하이퍼링크에 동일한 캡션을 공유합니다.
참고
경우는 DataTextField 및 Text 속성이 모두 설정의 DataTextField 속성이 우선 합니다.