DataImageUrlField Property

ImageField.DataImageUrlField Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the name of the field from the data source that contains the values to bind to the ImageUrl property of each image in an ImageField object.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public virtual string DataImageUrlField { get; set; }
/** @property */
public String get_DataImageUrlField ()

/** @property */
public void set_DataImageUrlField (String value)

public function get DataImageUrlField () : String

public function set DataImageUrlField (value : String)

Property Value

The name of the field to bind to the ImageUrl property of each image in an ImageField object.

Use the DataImageUrlField property to specify the name of the field to bind to the ImageUrl property of each image in an ImageField object. The specified field must contain the URLs for the images to display in the ImageField object. You can optionally format the URL values by setting the DataImageUrlFormatString property.

NoteNote

When the filed value is a null reference (Nothing in Visual Basic), an image cannot be displayed. You can display an alternate image for a null reference (Nothing in Visual Basic) field values by setting the NullImageUrl property. Instead of an alternate image, you can display alternate text by setting the NullDisplayText property.

The following example code demonstrates how to use the DataImageUrlField property to specify the name of the field to bind to the ImageUrl property of each image in an ImageField object.


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

<html>
  <body>
    <form 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>


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2016 Microsoft