Export (0) Print
Expand All

DataControlField.HeaderImageUrl Property

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

Gets or sets the URL of an image that is displayed in the header item of a data control field.

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

public virtual string HeaderImageUrl { get; set; }
/** @property */
public String get_HeaderImageUrl ()

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

public function get HeaderImageUrl () : String

public function set HeaderImageUrl (value : String)

Property Value

A string that represents a fully qualified or relative URL to an image that is displayed in the header item of the DataControlField.

Set the HeaderImageUrl property when you want an image displayed in the header item of a data control instead of header text.

NoteNote

If both the HeaderText and HeaderImageUrl properties are set, the HeaderImageUrl property has precedence.

The following code example demonstrates how to declaratively set the HeaderImageUrl property of a ButtonField column, which displays an image in the GridView control's column header instead of header text.

<%@ page language="C#" %>
<html>
<body>
  <form runat="server">
    <asp:sqldatasource
      id="SqlDataSource1"
      runat="server"
      connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
      selectcommand="SELECT EmployeeID, FirstName, LastName, Title, Region FROM Employees">
    </asp:sqldatasource>

    <asp:gridview
      id="GridView1"
      runat="server"
      allowpaging="True"
      datasourceid="SqlDataSource1"
      allowsorting="True"
      width="472px">
        <columns>

          <asp:buttonfield
            headerimageurl="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
            text="ClickMe"
            showheader="True"
            buttontype="Button">
          </asp:buttonfield>

        <asp:hyperlinkfield
          target="http://msdn.microsoft.com/"
          headertext="Link To Info"
          text="MyLink">
            <headerstyle backcolor="Yellow">
            </headerstyle>
        </asp:hyperlinkfield>

      </columns>
    </asp:gridview>

  </form>
</body>
</html>

<%@ page language="VJ#" %>
<html>
<body>
  <form runat="server">
    <asp:sqldatasource
      id="SqlDataSource1"
      runat="server"
      connectionstring="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"
      selectcommand="Select EmployeeID, FirstName, LastName, Title, Region From Employees">
    </asp:sqldatasource>

    <asp:gridview
      id="GridView1"
      runat="server"
      allowpaging="True"
      datasourceid="SqlDataSource1"
      allowsorting="True"
      width="472px">
        <columns>

          <asp:buttonfield
            headerimageurl="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
            text="ClickMe"
            showheader="True"
            buttontype="Button">
          </asp:buttonfield>

        <asp:hyperlinkfield
          target="http://msdn.microsoft.com/"
          headertext="Link To Info"
          text="MyLink">
            <headerstyle backcolor="Yellow">
            </headerstyle>
        </asp:hyperlinkfield>

      </columns>
    </asp:gridview>

  </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:
© 2014 Microsoft