Binding the header text of a GridView column?

Discussion in 'ASP .Net' started by Hans Merkl, Nov 9, 2005.

  1. Hans Merkl

    Hans Merkl Guest

    Hi,

    I was wondering if it's possible to bind the header text of a GridView
    column to a method of an object I have. At the moment I am setting the
    header texts in Page_Load but I was wondering if I can do with databinding.

    thanks

    Hans Merkl
     
    Hans Merkl, Nov 9, 2005
    #1
    1. Advertising

  2. Hans,

    If you convert the column into a TemplateColumn, you can specify a
    HeaderTemplate where you can put any binding code you want. If your object
    isn't public or protected, expose a public or protected property of the page
    code behind that returns the results of the method call.

    Tim

    "Hans Merkl" wrote:

    > Hi,
    >
    > I was wondering if it's possible to bind the header text of a GridView
    > column to a method of an object I have. At the moment I am setting the
    > header texts in Page_Load but I was wondering if I can do with databinding.
    >
    > thanks
    >
    > Hans Merkl
    >
     
    =?Utf-8?B?dGlta2xpbmc=?=, Nov 10, 2005
    #2
    1. Advertising

  3. Hi Hans,

    I think Hans's suggestion on using TemplateField is reasonable. The
    build-in fields can not allow inline databinding expression, so we have to
    utitlize the templateField which can allow define inline html template for
    Header and other Item...

    If there're any other questions, please feel free to post here.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | Thread-Topic: Binding the header text of a GridView column?
    | thread-index: AcXljgQYg2NmbV8jRPykLS8iuiWXXQ==
    | X-WBNR-Posting-Host: 70.59.48.45
    | From: "=?Utf-8?B?dGlta2xpbmc=?=" <>
    | References: <11pfefdu1j392$.1vih2zxswxcot$>
    | Subject: RE: Binding the header text of a GridView column?
    | Date: Wed, 9 Nov 2005 16:30:56 -0800
    | Lines: 21
    | Message-ID: <>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="Utf-8"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | Content-Class: urn:content-classes:message
    | Importance: normal
    | Priority: normal
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet:356877
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Hans,
    |
    | If you convert the column into a TemplateColumn, you can specify a
    | HeaderTemplate where you can put any binding code you want. If your
    object
    | isn't public or protected, expose a public or protected property of the
    page
    | code behind that returns the results of the method call.
    |
    | Tim
    |
    | "Hans Merkl" wrote:
    |
    | > Hi,
    | >
    | > I was wondering if it's possible to bind the header text of a GridView
    | > column to a method of an object I have. At the moment I am setting the
    | > header texts in Page_Load but I was wondering if I can do with
    databinding.
    | >
    | > thanks
    | >
    | > Hans Merkl
    | >
    |
     
    Steven Cheng[MSFT], Nov 10, 2005
    #3
  4. Hans Merkl

    Hans Merkl Guest

    Tim,

    This works. Thanks a lot.

    Hans


    > Hans,
    >
    > If you convert the column into a TemplateColumn, you can specify a
    > HeaderTemplate where you can put any binding code you want. If your object
    > isn't public or protected, expose a public or protected property of the page
    > code behind that returns the results of the method call.
    >
    > Tim
    >
    > "Hans Merkl" wrote:
    >
    >> Hi,
    >>
    >> I was wondering if it's possible to bind the header text of a GridView
    >> column to a method of an object I have. At the moment I am setting the
    >> header texts in Page_Load but I was wondering if I can do with databinding.
    >>
    >> thanks
    >>
    >> Hans Merkl
    >>
     
    Hans Merkl, Nov 10, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Smith
    Replies:
    0
    Views:
    549
    Greg Smith
    Apr 12, 2007
  2. TS
    Replies:
    4
    Views:
    952
  3. Keith G Hicks
    Replies:
    3
    Views:
    793
    Keith G Hicks
    Feb 18, 2008
  4. hansiman

    Image in header column (not replacing column header text)

    hansiman, Feb 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    323
    hansiman
    Feb 7, 2004
  5. Necqui Teja

    Retrieve GridView column header text on sort

    Necqui Teja, Nov 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    427
    Steven Cheng[MSFT]
    Nov 15, 2005
Loading...

Share This Page