473,394 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Binding the header text of a GridView column?

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
Nov 19 '05 #1
3 3456
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

Nov 19 '05 #2
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=?=" <ti******@discussions.microsoft.com>
| References: <11*******************************@40tude.net>
| Subject: RE: Binding the header text of a GridView column?
| Date: Wed, 9 Nov 2005 16:30:56 -0800
| Lines: 21
| Message-ID: <F4**********************************@microsoft.co m>
| 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
| >
|

Nov 19 '05 #3
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

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shravan Kumar | last post by:
Hi, I am using my code to set column widths of datagrid columns dynamically, but when I am setting the column widths to zero, the header text of the column whose width is made to zero is...
4
by: lanem | last post by:
I want an image and text in the column header in my GridView. Does anyone know how to do that? Thanks.
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
8
by: fredd00 | last post by:
hi i'm trying to change the gridview columns header text the columns are not auto generated, i have set specific headertext values for each column i want to change the header text based on...
1
by: AD | last post by:
Hi, I have a problem where my text in a GridView column is being wrapped in the middle of the column and does not fill the full width of the column, any idea why this would happen, and how I can...
2
by: L.Peter | last post by:
Hi Group, I have a gridview with 20 columns column1, column2 ... Is it possible to display the text of column header vertically. i.e: c o l u m
4
by: Yin99 | last post by:
I have a Gridview binding to a DataTable source. I'd like to set the column with of the second column. I cannot do this apparently because when AutoGenerateColumns=true, they do not appear in the...
1
by: ASPnewb1 | last post by:
this is used when the Updating Row is fired the first line works in grabbing the text from the textbox of the cell, but I cannot access the column header text, as it's telling me the columns do...
1
by: Amit00 | last post by:
Hi, I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that: foreach (DataControlField col in GridView1.Columns)...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.