473,545 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting text in HeaderTemplate, how??

ASP.NET 2.0

I have a webpage which contains a GridView. I want this GridView's
HeaderTemplate to display the text "Inbox" or "Outbox"... So I think I need
to set the value in the code behind file... Anyone got any tips about how to
do this?

Jeff
Mar 12 '07 #1
8 9136
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:eS******** ******@TK2MSFTN GP05.phx.gbl...
I have a webpage which contains a GridView. I want this GridView's
HeaderTemplate to display the text "Inbox" or "Outbox"... So I think I
need to set the value in the code behind file... Anyone got any tips about
how to do this?
When you say HeaderTemplate, do you mean you want to overwrite the text in
the first column's header...?

Or are you actually thinking of the GridView's Caption property...?
Mar 12 '07 #2

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:eX******** ******@TK2MSFTN GP04.phx.gbl...
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:eS******** ******@TK2MSFTN GP05.phx.gbl...
>I have a webpage which contains a GridView. I want this GridView's
HeaderTempla te to display the text "Inbox" or "Outbox"... So I think I
need to set the value in the code behind file... Anyone got any tips
about how to do this?

When you say HeaderTemplate, do you mean you want to overwrite the text in
the first column's header...?

Or are you actually thinking of the GridView's Caption property...?
Yes, I want to overwrite the text in the HeaderTemplate
Mar 12 '07 #3
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:ev******** ******@TK2MSFTN GP05.phx.gbl...
>When you say HeaderTemplate, do you mean you want to overwrite the text
in the first column's header...?

Or are you actually thinking of the GridView's Caption property...?

Yes, I want to overwrite the text in the HeaderTemplate
<MyGridView>.Co lumns[0].HeaderText = "Inbox";
Mar 12 '07 #4

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:OE******** ******@TK2MSFTN GP03.phx.gbl...
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:ev******** ******@TK2MSFTN GP05.phx.gbl...
>>When you say HeaderTemplate, do you mean you want to overwrite the text
in the first column's header...?

Or are you actually thinking of the GridView's Caption property...?

Yes, I want to overwrite the text in the HeaderTemplate

<MyGridView>.Co lumns[0].HeaderText = "Inbox";
thanks, but somehow the text isn't displayed. I here post the markup of my
gridview so you can see if there are something wrong with the markup:
<asp:GridView ID="gridMessage "
Width="100%"
AutoGenerateCol umns="false"
OnRowDataBound= "gridMessage_Ro wDataBound"
runat="server"
BorderWidth="0"
BorderStyle="No ne"
RowStyle-BackColor="#EBE BEB"
AlternatingRowS tyle-BackColor="#D9D 9D9"
DataSourceID="o dsMessage">
<Columns>
<asp:TemplateFi eld ControlStyle-Width="100%"
HeaderStyle-Width="100%">
<HeaderTemplate >
</HeaderTemplate>
<ItemTemplate >
<some text here>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>

In the open event I set the text:
gridMessage.Col umns[0].HeaderText = "Inbox";

In order to keep the markup I posted here tidy I removed the contents inside
the column and replaced it with this text <some text here>....

Any suggestions?
Mar 12 '07 #5
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:OM******** ******@TK2MSFTN GP03.phx.gbl...
In the open event I set the text:
gridMessage.Col umns[0].HeaderText = "Inbox";
The "open" event...? Do you mean Page_Load?

If so, that's too early - you need to set this *after* the data has been
bound to the GridView, otherwise it will be overwritten...

gridMessage.Dat aSource = "<......>";
gridMessage.Dat aBind();
gridMessage.Col umns[0].HeaderText = "Inbox";
Mar 12 '07 #6

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:eg******** ******@TK2MSFTN GP05.phx.gbl...
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:OM******** ******@TK2MSFTN GP03.phx.gbl...
>In the open event I set the text:
gridMessage.Co lumns[0].HeaderText = "Inbox";

The "open" event...? Do you mean Page_Load?

If so, that's too early - you need to set this *after* the data has been
bound to the GridView, otherwise it will be overwritten...

gridMessage.Dat aSource = "<......>";
gridMessage.Dat aBind();
gridMessage.Col umns[0].HeaderText = "Inbox";
Yes, I mean Page_Load

I've tryed to set it in the gridMessage_Row DataBound (RowDataBound) which
didn't help - no HeaderText displayed.

Thanks for this example:
gridMessage.Dat aSource = "<......>";
gridMessage.Dat aBind();
gridMessage.Col umns[0].HeaderText = "Inbox";
But I doesn't make any call to DataBind() in the code-behind file. All is
done in the markup... So I'm a bit lost about where to place this
gridMessage.Col umns[0].HeaderText = "Inbox";

Any suggestion

Mar 12 '07 #7
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:O2******** ******@TK2MSFTN GP05.phx.gbl...
Thanks for this example:
gridMessage.Dat aSource = "<......>";
gridMessage.Dat aBind();
gridMessage.Col umns[0].HeaderText = "Inbox";
But I doesn't make any call to DataBind() in the code-behind file. All is
done in the markup... So I'm a bit lost about where to place this
gridMessage.Col umns[0].HeaderText = "Inbox";
Ah right...

In which case, you could try Page_PreRender. ..
Mar 12 '07 #8

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:ON******** ******@TK2MSFTN GP03.phx.gbl...
"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:O2******** ******@TK2MSFTN GP05.phx.gbl...
>Thanks for this example:
gridMessage.Da taSource = "<......>";
gridMessage.Da taBind();
gridMessage.Co lumns[0].HeaderText = "Inbox";
>But I doesn't make any call to DataBind() in the code-behind file. All is
done in the markup... So I'm a bit lost about where to place this
gridMessage.Co lumns[0].HeaderText = "Inbox";

Ah right...

In which case, you could try Page_PreRender. ..
Thanks... At first Page_PreRender didn't help, so I was tweaking around my
code and also tryed the PreRender event of my GridView... it didn't help
here either... But hey I've found why it didn't work... the markup of my
GridView contains <HeaderTemplate ></HeaderTemplate> ... After I removed these
tags the gridMessage.Col umns[0].HeaderText = "Inbox"; works as a dream...

I post how I've solved it just in case somebody else would came across the
same problem and are looking for a solution

Jeff
Mar 13 '07 #9

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

Similar topics

0
1656
by: CoreyMas | last post by:
Hello Everyone, I have been successful in creating a template column programatically using the examples provided in VS 2003. However I have not been able to programatically set the width of a template column programatically Here is the code that I have used so far
0
303
by: Ashish Sharma | last post by:
Can i assign a datasource to the headerTemplate item in the datagrid ?, or can i acces a control specified in the HeaderTemplate of the Grid ?, like a dropdownlist specified in the headertemplate ? many thanks -ashish
4
9643
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater with like a table layout and in the last column I want to have three radio buttons (for each row in repeater). The value of the radio button should...
0
1162
by: ryan.d.rembaum | last post by:
I have posted q couple questions about databinding, but figured I'd simplify my questions and see if what I want to do is even possible. I have a database C:\mydatase.mdb In it there is a table tbleCategory In that table are two fields fldCat and fldID. I know how to use ASP and ADO to update a database at a click of a button by sending...
2
5563
by: John Haycock | last post by:
Hi All I have a user control that uses a repeater to build a list of menu links: <itemtemplate> <li> <a href='news.aspx?newsID=<%# DataBinder.Eval(Container.DataItem,"newsID") %>'> <%# DataBinder.Eval(Container.DataItem, "newsHeadline") %> </a> </li>
6
11060
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of...
4
9442
by: TS | last post by:
I have a headerText for a header column that is "Page<br>Name". it puts a <brto force a line break, but the < and get encoded to &lt; and &gt; thus negating its effect as an html control and doesn't respect the line break I'm guessing this happens during render. What do i need to do to keep the line break?
1
5562
by: Kbalz | last post by:
Hello, my headerfields are wider than the datafields, so I wanted to have my headerfields read vertically like: | | S | | | t | | F | o | | a | c | | b | k | -------- | Y | N |
1
416
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a repeater control with rows in made of of link buttons so that they react to a click as below: <div> <ASP:Repeater id="rptUserList" runat="server" OnItemCommand="rptUserList_ItemCommand" >
0
7410
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...
0
7668
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. ...
0
7923
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...
1
7437
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...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
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...
0
4960
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...
1
1901
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
0
722
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...

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.