CommandField.SelectImageUrl 속성

정의

CommandField 필드의 새로 만들기 단추에 대해 표시할 이미지의 URL을 가져오거나 설정합니다.

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

속성 값

CommandField의 선택 단추에 대해 표시할 이미지의 URL입니다. 기본값은 빈 문자열("")로, 이 속성이 설정되어 있지 않음을 나타냅니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 SelectImageUrl 선택 단추에 대해 표시할 사용자 지정 이미지를 지정 하는 속성을 CommandField 필드를 GridView 컨트롤. 합니다 ButtonType 속성으로 설정 되어 있어야 ButtonType.Image 이미지를 표시 하려면 선택 단추에 대 한 합니다.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
  void CustomersGridView_SelectedIndexChanged(Object sender, EventArgs e)
  {
    // Retrieve the company name from the appropriate cell.
    String companyName = CustomersGridView.SelectedRow.Cells[2].Text;
   
    // Display company name selected by the user.
    Message.Text = "You selected " + companyName + ".";
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>CommandField Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>CommandField Example</h3>
      
      <asp:Label id="Message"
        forecolor="Red"
        runat="server"/>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"
        onselectedindexchanged="CustomersGridView_SelectedIndexChanged"   
        runat="server">
        
        <columns>
          <asp:commandfield showselectbutton="true"
            buttontype="Image"
            selectimageurl="~\Images\SelectButton.jpg"
            headertext="Select Customer"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="VB" AutoEventWireup="False" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
  Sub CustomersGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CustomersGridView.SelectedIndexChanged
    
    ' Retrieve the company name from the appropriate cell.
    Dim companyName As String = CustomersGridView.SelectedRow.Cells(2).Text
   
    ' Display company name selected by the user.
    Message.Text = "You selected " & companyName & "."
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>CommandField Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>CommandField Example</h3>
      
      <asp:Label id="Message"
        forecolor="Red"
        runat="server"/>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        datakeynames="CustomerID"  
        runat="server">
        
        <columns>
          <asp:commandfield showselectbutton="true"
            buttontype="Image"
            selectimageurl="~\Images\SelectButton.jpg"
            headertext="Select Customer"/>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID" />
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

설명

때를 ButtonType 의 속성을 CommandField 필드로 설정 됩니다 ButtonType.Image를 사용 하 여를 SelectImageUrl 선택 단추에 대해 표시할 이미지를 지정 하는 속성. 이 이미지는 클라이언트의 브라우저에서 해당 형식을 지원으로 모든 파일 형식 (.jpg,.gif,.bmp, 및 등) 수 있습니다.

참고

이미지 선택 단추를 표시 하는 대신, 첫 번째 설정에 따라 텍스트를 표시 합니다 ButtonType 속성을 ButtonType.Button 또는 ButtonType.Link 로 설정한를 SelectText 속성.

적용 대상

추가 정보