473,799 Members | 3,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using labels within datagrid template headings

Hi all,

Am I allowed to use labe;s within the datagrid heading section? Each time I
drag a label onto the design, I can set the properties and such (including
runat=server) but the code-behind refuses to accept/acknowledge it's
existence.

Am I just doing something wrong and if so, what?

Regards
John.
Nov 19 '05 #1
2 974
John,

If you want to programatically access a control which is part of a DataGrid, you need to handle it in the ItemDataBound event.

your code will look something like this in the ItemDataBound event handler:

if(e.ItemType == ListItemType.It em || e.ItemType == ListItemType.Al ternateItem)
{
Label lbl = (Label)e.Item.F indControl("con trolName");
lbl.Text = "Hello World";
}

Hope this helps.

"John" <a@b.com> wrote in message news:uI******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

Am I allowed to use labe;s within the datagrid heading section? Each time I
drag a label onto the design, I can set the properties and such (including
runat=server) but the code-behind refuses to accept/acknowledge it's
existence.

Am I just doing something wrong and if so, what?

Regards
John.

Nov 19 '05 #2
Man oh man . . .

It worked - THANKS

I understand how that would work - I already have quite a bit of items I'm
binding to within the ItemDataBound sub but didn't realize that for headers,
it fires up once so I can set them up.

Again, thanks.

Regards
John.

"Steven Berkovitz" <mb****@communi ty.nospam> wrote in message
news:e5******** ******@TK2MSFTN GP14.phx.gbl...
John,

If you want to programatically access a control which is part of a DataGrid,
you need to handle it in the ItemDataBound event.

your code will look something like this in the ItemDataBound event handler:

if(e.ItemType == ListItemType.It em || e.ItemType ==
ListItemType.Al ternateItem)
{
Label lbl = (Label)e.Item.F indControl("con trolName");
lbl.Text = "Hello World";
}

Hope this helps.

"John" <a@b.com> wrote in message
news:uI******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

Am I allowed to use labe;s within the datagrid heading section? Each time
I
drag a label onto the design, I can set the properties and such (including
runat=server) but the code-behind refuses to accept/acknowledge it's
existence.

Am I just doing something wrong and if so, what?

Regards
John.

Nov 19 '05 #3

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

Similar topics

0
1743
by: NETDeveloper | last post by:
Hi, I almost have my nested datagrid working properly. I created a datagrid on a user control and dropped that onto another datagrid. At first, I noticed when I was stepping through the code, that the update linkbutton actually goes to the edit command instead of the update command (which I'm pretty sure would be a bug). Anyway, I took out the editcommmand column and replaced it with a regular template column. Within the...
3
2271
by: daveS | last post by:
I have come accross the exact same problem as below. The address that was given as a solution cannot be found. Specifically, i need to be able to show labels in only the first column of a report! Could someone please help! ***************************************************** Message 6 in thread From: fredg (fgutkind@att.net) Subject: Re: Row headings in a column-based report
1
1432
by: Randy | last post by:
Hello, I've got an ASP app. I have a simple datagrid. If I don't use column templates I can easily set up the datagrid to use paging by creating a PageIndexChanged event and putting this code in it... DataGrid1.CurrentPageIndex = e.NewPageIndex; DataGrid1.DataBind(); This works fine. But when I then use column styles for the datagrid using Labels in the item template slot, when I click the next page link at the bottom of the datagrid,...
0
1550
by: Earl Teigrob | last post by:
I have created a templated custom control that simply creates a spacing table around other objects. This control works fine for most uses but when I add it inside the ItemTemplate of a DataGrid Control, Container.DataItem of the DataGrid control can no longer be access from within the template of my custom control. Is there a way to qualify the Container.DataItem object or some other method for me to access it from within my templated...
2
4696
by: SaT | last post by:
Does anyone know how to create hyperlink labels within a datagrid, on the fly? Thanks SaT
2
13537
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to execute a MailMerge to create mailing labels or customized letters. A label name known to MS Word MailMerge mailing label wizard may be used or a template file containing the field names Line1 thru Line5 for each record to be printed. If a...
8
4209
by: mark4asp | last post by:
How can I get spans which look like buttons. These buttons have a fixed height (24px), variable width, a thin (1px) solid border and a background image. The back-ground image is a slice 24px high, 1px wide, repeated: For instance a span <span class="ButtonLeft">: ..ButtonLeft {
1
1705
by: Izhaki | last post by:
Hi, I'm creating a system where my XML includes HTML tags (<h1></h1>) in addition to other XML elements (<book></book>). I would like to render the HTML tags back to HTML using XSL. Considering I want to replace all headings, I could do for each heading level (i.e. repeat the following code for h2, h3, h4, h5, etc.): <xsl:template match="h1"> <h1><xsl:apply-templates/></h1> </xsl:template>
4
3920
by: saritha2008 | last post by:
Hi, Iam working on converting one of xml file to other form of xml using XSLT. As part of this, I need to count the no. of "component" nodes in the xml file given below. If there is only one "component" node,i have to assign the value of this node to "component" node in my output.xml file. If there are more than one "component" nodes in my input xml file, then i should take the first "component" alphabetically that does not start with a...
0
9688
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
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
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
9078
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...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.