473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

boundcolumn headertext set to a code-behind variable?

I have an ASP.NET datagrid with several bound columns. I need to make the
header of some of these columns display a string that is generated from the
code behind (i.e. a dynamic header). How is this done?

I have tried with both a templatecolumn and boundcolumn. I thought it might
be something like: HeaderText='<%# DataBinder.Eval(Container,
"DataItem.myVariable") %>' or HeaderText='<% Response.Write(myVariable); %>
But, neither worked, nor did several variations. I just want the headertext
to display myVariable which is declared as a string. Can anyone please
assist?

TIA,
John
Nov 18 '05 #1
4 3903
John,

In code-behind (not in .aspx file) you can set HeaderText property via
Columns property of the datagrid.

Eliyahu

"John E." <pl*********@newsgroup.thanks> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
I have an ASP.NET datagrid with several bound columns. I need to make the
header of some of these columns display a string that is generated from the code behind (i.e. a dynamic header). How is this done?

I have tried with both a templatecolumn and boundcolumn. I thought it might be something like: HeaderText='<%# DataBinder.Eval(Container,
"DataItem.myVariable") %>' or HeaderText='<% Response.Write(myVariable); %> But, neither worked, nor did several variations. I just want the headertext to display myVariable which is declared as a string. Can anyone please
assist?

TIA,
John

Nov 18 '05 #2
I tried that originally, and it sets the headertext during page load, but
after it is loaded the headertext keeps getting reset to the .aspx value.
Even if I remove the HeaderText item from the .aspx portion.

So, if it is done in the code-behind, how do you make sure it is the final
setting that the headertext is set to?

Sorry about my ignorance, but I am used to doing applications, not asp.

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
John,

In code-behind (not in .aspx file) you can set HeaderText property via
Columns property of the datagrid.

Eliyahu

"John E." <pl*********@newsgroup.thanks> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
I have an ASP.NET datagrid with several bound columns. I need to make the header of some of these columns display a string that is generated from the
code behind (i.e. a dynamic header). How is this done?

I have tried with both a templatecolumn and boundcolumn. I thought it

might
be something like: HeaderText='<%# DataBinder.Eval(Container,
"DataItem.myVariable") %>' or HeaderText='<%

Response.Write(myVariable); %>
But, neither worked, nor did several variations. I just want the

headertext
to display myVariable which is declared as a string. Can anyone please
assist?

TIA,
John


Nov 18 '05 #3
Try doing this in PreRender event.

Eliyahu

"John E." <pl*********@newsgroup.thanks> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
I tried that originally, and it sets the headertext during page load, but
after it is loaded the headertext keeps getting reset to the .aspx value.
Even if I remove the HeaderText item from the .aspx portion.

So, if it is done in the code-behind, how do you make sure it is the final
setting that the headertext is set to?

Sorry about my ignorance, but I am used to doing applications, not asp.

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
John,

In code-behind (not in .aspx file) you can set HeaderText property via
Columns property of the datagrid.

Eliyahu

"John E." <pl*********@newsgroup.thanks> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
I have an ASP.NET datagrid with several bound columns. I need to make the header of some of these columns display a string that is generated from
the
code behind (i.e. a dynamic header). How is this done?

I have tried with both a templatecolumn and boundcolumn. I thought it

might
be something like: HeaderText='<%# DataBinder.Eval(Container,
"DataItem.myVariable") %>' or HeaderText='<%

Response.Write(myVariable);
%>
But, neither worked, nor did several variations. I just want the

headertext
to display myVariable which is declared as a string. Can anyone

please assist?

TIA,
John



Nov 18 '05 #4
Got it. Thanks! Setting the sessions to their local/member variables
within the init, also helped to keep me from loosing those assignments and
now everything renders properly :D

Thanks again,
John

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:OV***************@TK2MSFTNGP15.phx.gbl...
Try doing this in PreRender event.

Eliyahu

"John E." <pl*********@newsgroup.thanks> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
I tried that originally, and it sets the headertext during page load, but
after it is loaded the headertext keeps getting reset to the .aspx value. Even if I remove the HeaderText item from the .aspx portion.

So, if it is done in the code-behind, how do you make sure it is the final setting that the headertext is set to?

Sorry about my ignorance, but I am used to doing applications, not asp.

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
John,

In code-behind (not in .aspx file) you can set HeaderText property via
Columns property of the datagrid.

Eliyahu

"John E." <pl*********@newsgroup.thanks> wrote in message
news:eI**************@TK2MSFTNGP15.phx.gbl...
> I have an ASP.NET datagrid with several bound columns. I need to make
the
> header of some of these columns display a string that is generated

from the
> code behind (i.e. a dynamic header). How is this done?
>
> I have tried with both a templatecolumn and boundcolumn. I thought
it might
> be something like: HeaderText='<%# DataBinder.Eval(Container,
> "DataItem.myVariable") %>' or HeaderText='<%

Response.Write(myVariable);
%>
> But, neither worked, nor did several variations. I just want the
headertext
> to display myVariable which is declared as a string. Can anyone

please > assist?
>
> TIA,
> John
>
>



Nov 18 '05 #5

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

Similar topics

0
by: sam | last post by:
Hello Group, I have a currency column and I display values according to the dataformat string as below: <asp:BoundColumn DataField="Revenue" SortExpression="Revenue" HeaderText="Revenue"...
3
by: John | last post by:
The ItemCommand event not getting fired when I add both a BoundColumn and a ButtonColumn to a datagrid. When I add a ButtonColumn by itself, everything works fine, but as soon as I add a...
0
by: cntams | last post by:
Hi all, I have a Web Form and using BoundColumn to bind data to the datagrid. I have 2 fields that needs to be formatted. The first one is a DateTime field and the second one is the currency...
1
by: niki | last post by:
Hello. I have a problem with custom columns inside the datagrid. I've set up a datagrid that populates from a database; I can edit the datagrid values and update the db, so that's ok. (btw, it's...
2
by: tshad | last post by:
Is there a way to call a function from a boundcolumn tag? I have some icons that I set as visible or not depending on values set in my table. I have a Datagrid that I am binding to and after...
3
by: tshad | last post by:
In a datagrid, is there a way to put a tooltip and use a field from the data that is returned from the sql statement to fill it? For example: <asp:BoundColumn DataField="CompanyDesc"...
4
by: Randall Parker | last post by:
Using ASP.Net v1.1 with C#. I have an asp:DataGrid where one column is specified as follows: <asp:BoundColumn HeaderText="Serial" DataField="owner_serial_num"></asp:BoundColumn> I might get...
0
by: hazz | last post by:
The following code generates checkbox values from the database. Once the user selects/deselects checkbox values, is there a way to obtain the ID and Checkbox.Checked state from these BoundColumns...
1
by: jeffg | last post by:
Hi, I have a DataGrid in a ASP.NET application (.NET 1.1) where one of the BoundColumns in the datagrid is displaying a Date and Time stamp. I would like to display just a short date...
1
by: rn5a | last post by:
A DataGrid has a BoundColumn which changes to a TextBox when the DataGrid is in the editable mode. The rest of the columns in the DataGrid are TemplateColumns. There's an EditCommandColumn as well....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.