473,624 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3472
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: AcXljgQYg2NmbV8 jRPykLS8iuiWXXQ ==
| X-WBNR-Posting-Host: 70.59.48.45
| From: "=?Utf-8?B?dGlta2xpbmc =?=" <ti******@discu ssions.microsof t.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************ *************** *******@microso ft.com>
| 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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GXA03.phx.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3568 77
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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
3345
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 appearing on the existing column headers, and the text gets blurred with the painting of the column text along with the adjacent width 0 column. Anybody, can you please give me a solution for it
4
3911
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
2420
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 a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
8
31965
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 the specific header text. i want to load a new text from a global resource file. what i'm actually trying to do and is not working :
1
27383
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 control it? Thanks
2
4798
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
25521
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 columns collection. I modified the RowCreated even to gridview, and I can change properties on the cells, but not width. (setting tooltip, background color, etc, all work but changing width has no effect). Here's sample code I am using:
1
4874
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 not exist. cName = (System.Web.UI.WebControls.TextBox)GridView2.Rows.Cells.Controls; //Cells.Controls; cName.Text = GridView2.Columns.HeaderText. + "=" + cName;
1
2071
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) { col.HeaderText = GetString(col.HeaderText); } However, no matter where I place that code, the header texts return to their original value, and that's what's being displayed.
0
8236
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8173
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.