Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Using labels in the HeaderTemplate of a datagrid or datalist

Reply
Thread Tools

Using labels in the HeaderTemplate of a datagrid or datalist

 
 
ree32
Guest
Posts: n/a
 
      09-21-2004
when I try to access this label to place a text in it in the code. I
get this error -
Object reference not set to an instance of an object.


I assume this because the label is within the datalist I can't get a
control of it.

Is there anyway around this?
 
Reply With Quote
 
 
 
 
Michael Tkachev
Guest
Posts: n/a
 
      09-21-2004
Why do you want to use a lable in the header?

"ree32" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> when I try to access this label to place a text in it in the code. I
> get this error -
> Object reference not set to an instance of an object.
>
>
> I assume this because the label is within the datalist I can't get a
> control of it.
>
> Is there anyway around this?



 
Reply With Quote
 
 
 
 
ree32
Guest
Posts: n/a
 
      09-21-2004
I need to use a label as the Text dynamically changes. As this
datagrid/list is in a usercountrol. Different headings will be fed
into the user control.
 
Reply With Quote
 
Michael Tkachev
Guest
Posts: n/a
 
      09-21-2004
You can use the following code:

datagrid.Columns[0].HeaderText = "bla-bla";



"ree32" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I need to use a label as the Text dynamically changes. As this
> datagrid/list is in a usercountrol. Different headings will be fed
> into the user control.



 
Reply With Quote
 
ree32
Guest
Posts: n/a
 
      09-21-2004
"Michael Tkachev" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> You can use the following code:
>
> datagrid.Columns[0].HeaderText = "bla-bla";
>
>


You have it wrong this is not the header of the column but the header
of the whole datagrid/datalist.
 
Reply With Quote
 
Gary K
Guest
Posts: n/a
 
      09-23-2004
Then why is the text in a headertemplate? Anyways, to change any control in a
template column you need to use the FindControls method. For events you can
get away with something like, e.Item.FindControl("ctrlid"). It returns a
general object so you will need to typecast it. Outside events I'd use
grid.Rows.FindControl("ctrlid").

"ree32" wrote:

> "Michael Tkachev" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> > You can use the following code:
> >
> > datagrid.Columns[0].HeaderText = "bla-bla";
> >
> >

>
> You have it wrong this is not the header of the column but the header
> of the whole datagrid/datalist.
>

 
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
Getting checkbox value from DataList.HeaderTemplate for use in ServerValidate event Andy B. ASP .Net 0 02-20-2009 06:36 PM
CheckBox Outside DataList & Labels Inside DataList rn5a@rediffmail.com ASP .Net 1 12-24-2006 02:28 PM
Datalist HeaderTemplate repeating duplicates? - sort, break, grouping? jobs at webdos ASP .Net 2 10-08-2006 01:22 PM
Control loses viewstate inside HeaderTemplate of DataList Fahim ASP .Net 0 08-18-2006 12:17 PM



Advertisments