다음을 통해 공유


HyperLinkField.DataNavigateUrlFormatString 속성

정의

HyperLinkField 개체의 하이퍼링크에 대한 URL이 렌더링되는 형식을 지정하는 문자열을 가져오거나 설정합니다.

public:
 virtual property System::String ^ DataNavigateUrlFormatString { System::String ^ get(); void set(System::String ^ value); };
public virtual string DataNavigateUrlFormatString { get; set; }
member this.DataNavigateUrlFormatString : string with get, set
Public Overridable Property DataNavigateUrlFormatString As String

속성 값

String

HyperLinkField의 하이퍼링크에 대한 URL이 렌더링되는 형식을 지정하는 문자열입니다. 기본값은 빈 문자열("")로, 특수 형식이 URL 값에 적용되지 않음을 나타냅니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 DataNavigateUrlFormatString 속성에 표시 되는 하이퍼링크의 탐색 Url에 적용할 사용자 지정 형식 지정을 HyperLinkField 개체입니다. 지정 된 필드의 값을 DataTextField 속성이 형식 문자열에 지정 된 웹 페이지에 쿼리 문자열로 전달 됩니다.


<%@ 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>

설명

사용 하 여 합니다 DataNavigateUrlFormatString 속성에 있는 하이퍼링크의 Url에 대 한 사용자 지정 형식을 지정 하는 HyperLinkField 개체입니다. 경우는 DataNavigateUrlFormatString 속성이 설정 되지 않은, 특수 형식이 하이퍼링크의 Url 가져오지 못합니다.

참고

형식 문자열이 적용 되 경우에만 DataNavigateUrlFields 속성을 설정 합니다.

형식 문자열 리터럴 문자열일 수 있습니다 및 일반적으로 필드의 값에 대 한 자리 표시자를 포함 합니다. 예를 들어 형식 문자열에서에서 "항목 값: {0}"의 {0} 자리 표시자에 필드의 값으로 대체 됩니다는 HyperLinkField 개체입니다. 형식 문자열의 나머지 부분 리터럴 텍스트로 표시 됩니다.

참고

형식 문자열에 자리 표시 자가 포함 되어 있지 않으면, 데이터 원본에서 필드의 값 최종 표시 텍스트에 포함 되지 않습니다.

콜론으로 구분 하 고 중괄호를 형식에서에 래핑된 두 부분으로 이루어져 있습니다 자리 표시자 {A:Bxx}. 콜론 앞 값 (A 예:에서) 필드 값의 인덱스 0부터 시작 하는 매개 변수 목록을 지정 합니다.

참고

이 매개 변수는 서식 구문의 일부입니다. 각 셀에서 필드를 하나만 값 이기 때문에이 값을 0으로 설정할 수만 있습니다.

콜론 및 콜론 뒤의 값은 선택적입니다. 콜론 문자 (B 예:에서) 값을 표시 하는 형식을 지정 합니다. 다음 표에서 일반 형식을 나열합니다.

형식 문자 Description
C 통화 형식으로 숫자 값을 표시합니다.
D 10 진수 형식의 숫자 값을 표시합니다.
E 과학적 (지 수)의 숫자 값을 표시합니다.
F 고정 형식으로 숫자 값을 표시합니다.
G 숫자 값을 표시 일반적 서식을 지정합니다.
N 숫자 형식의 숫자 값을 표시합니다.
X 16 진수 형식의 숫자 값을 표시합니다.

참고

형식 문자를 제외 하 고 대 소문자를 구분 되지 X, 16 진수 문자를 지정 하는 경우를 표시 합니다.

형식 문자 뒤의 값 (xx 예:에서) 유효 자릿수 또는 소수 자릿수의 수를 지정 합니다. 예를 들어 형식 문자열 "{0:F2}" 두 개의 소수 자릿수로 고정 소수점 숫자를 표시 합니다.

문자열 형식 지정에 대한 자세한 내용은 형식 서식 지정을 참조하세요.

적용 대상

추가 정보