Binding the header text of a GridView column?

H

Hans Merkl

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
 
G

Guest

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
 
S

Steven Cheng[MSFT]

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=?=" <[email protected]>
| References: <[email protected]>
| Subject: RE: Binding the header text of a GridView column?
| Date: Wed, 9 Nov 2005 16:30:56 -0800
| Lines: 21
| Message-ID: <[email protected]>
| 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
| >
|
 
H

Hans Merkl

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top