Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid Headers

Reply
Thread Tools

Datagrid Headers

 
 
Chris Newald
Guest
Posts: n/a
 
      11-15-2007
Hello,

I have a simple gridview with one column on a web page. I need to be able to
set the column titles ("Header Title" below) programatically. How would I
do this easily in C#? I tried inserting an ASP Label but I cannot get the
FindControl to work for the Header Template.

<aspataGrid ID="alertGrid" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<b>Header Title</b>
</HeaderTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>

Thanks in advance,
Chris


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      11-15-2007
<HeaderTemplate>
<asp:Label runat="server" id="lblHeader" Text="Header Title" />
</HeaderTemplate>


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Chris Newald" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a simple gridview with one column on a web page. I need to be able

to
> set the column titles ("Header Title" below) programatically. How would I
> do this easily in C#? I tried inserting an ASP Label but I cannot get the
> FindControl to work for the Header Template.
>
> <aspataGrid ID="alertGrid" runat="server" AutoGenerateColumns="false">
> <Columns>
> <asp:TemplateColumn>
> <HeaderTemplate>
> <b>Header Title</b>
> </HeaderTemplate>
> </asp:TemplateColumn>
> </Columns>
> </aspataGrid>
>
> Thanks in advance,
> Chris
>
>



 
Reply With Quote
 
 
 
 
keithrull
Guest
Posts: n/a
 
      11-15-2007
On Nov 15, 11:50 am, "Chris Newald" <(E-Mail Removed)> wrote:
> Hello,
>
> I have a simple gridview with one column on a web page. I need to be able to
> set the column titles ("Header Title" below) programatically. How would I
> do this easily in C#? I tried inserting an ASP Label but I cannot get the
> FindControl to work for the Header Template.
>
> <aspataGrid ID="alertGrid" runat="server" AutoGenerateColumns="false">
> <Columns>
> <asp:TemplateColumn>
> <HeaderTemplate>
> <b>Header Title</b>
> </HeaderTemplate>
> </asp:TemplateColumn>
> </Columns>
> </aspataGrid>
>
> Thanks in advance,
> Chris


Add a label control in the header template then change it's value
inside the ItemDataBound event. I think it would be easier if you just
not put a header tempate and just use the column value of your
datasource instead.

Keith Rull
http://www.keithrull.com/
http://www.devpinoy.org/
 
Reply With Quote
 
Saad Saad is offline
Junior Member
Join Date: Oct 2007
Location: Karachi
Posts: 2
 
      11-16-2007
I think this should work for you,

alertGrid.Columns[0].HeaderText="Header Title";

where 0 is the index of column
 
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
Problem with wsgiref.headers.Headers Phil Python 4 01-17-2010 04:47 PM
Server cannot clear headers after HTTP headers have been sent Ian ASP .Net Security 2 03-20-2007 09:00 AM
Reading 'received' headers: Email Headers Parsing dont bother Python 0 03-03-2004 08:18 PM
Datagrid Headers??? Douglas Gage ASP .Net 0 01-15-2004 04:59 PM
locking headers in the Datagrid Nimbus Dorkus ASP .Net 2 07-09-2003 02:17 PM



Advertisments