DataControlField.HeaderImageUrl 属性

定义

获取或设置数据控件字段的标题项中显示的图像的 URL。

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

属性值

String

一个表示图像的完全限定或相对 URL 的字符串,该图像在 DataControlField 的标题项中显示。

示例

下面的代码示例演示如何以声明方式设置 HeaderImageUrl 列的属性,该属性 ButtonField 在控件的列标题而不是标题文本中 GridView 显示图像。

<%@ 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>ASP.NET Example</title>
</head>
<body>
  <form id="form1" 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="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>ASP.NET Example</title>
</head>
<body>
  <form id="form1" 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>

注解

HeaderImageUrl如果希望数据控件的标头项中显示的图像而不是标题文本,请设置属性。

备注

如果同时设置了属性 HeaderTextHeaderImageUrl 属性,则 HeaderImageUrl 属性具有优先级。

适用于

另请参阅