Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using labels within datagrid template headings

Reply
Thread Tools

Using labels within datagrid template headings

 
 
John
Guest
Posts: n/a
 
      04-10-2005
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.


 
Reply With Quote
 
 
 
 
Steven Berkovitz
Guest
Posts: n/a
 
      04-10-2005
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.Item || e.ItemType == ListItemType.AlternateItem)
{
Label lbl = (Label)e.Item.FindControl("controlName");
lbl.Text = "Hello World";
}

Hope this helps.

"John" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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.
>
>

 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      04-10-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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.Item || e.ItemType ==
ListItemType.AlternateItem)
{
Label lbl = (Label)e.Item.FindControl("controlName");
lbl.Text = "Hello World";
}

Hope this helps.

"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"pointlabel"-like function for Python: distribute text labels on a2-d scatter plot to avoid overlapping labels C Barrington-Leigh Python 1 09-12-2010 09:58 PM
Headings in the DataGrid Web Control =?Utf-8?B?QWxhbiBMYW1iZXJ0?= ASP .Net 10 03-05-2006 01:07 AM
Datagrid : massive headings when no data to display Bazza Formez ASP .Net 2 12-08-2004 11:23 PM
Re: Datagrid headings Saravana ASP .Net 1 07-23-2003 01:39 PM
Sorting in a DataGrid with no headings Tracey ASP .Net 0 07-23-2003 12:37 PM



Advertisments