473,320 Members | 2,080 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,320 software developers and data experts.

Setting column header text of datagrid in PreRender... Do You know how to do it?

I've a dropdownlist control to change language on my page. Because of page
lifetime, I have to set all my labels, texts etc. from ResourceManager in
prerender handler to be sure that culture change has been done. But I can't
set HeaderText property of DataGridColumn in prerender because it is
evaluated during data binding. I don't want to call DataBind() in
OnPreRender also... Any ideas?

I've tried to walk through Controls collection in PreRender, but it's very
poor, hard coded solution (and very problematic when we have some sortable
and not sortable columns)...

TIA
Adam
MCAD
Nov 19 '05 #1
4 6172
Adam,

If you are talking about autogenerated columns, the proper place for
changing their names is ItemCreated event.

For manually added columns you can use either ItemDataBound or PreRender
event. Note, that data binding takes place before PreRender.

Eliyahu

"Adam Boczek" <ad*********@gmx.de> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
I've a dropdownlist control to change language on my page. Because of page
lifetime, I have to set all my labels, texts etc. from ResourceManager in
prerender handler to be sure that culture change has been done. But I can't set HeaderText property of DataGridColumn in prerender because it is
evaluated during data binding. I don't want to call DataBind() in
OnPreRender also... Any ideas?

I've tried to walk through Controls collection in PreRender, but it's very
poor, hard coded solution (and very problematic when we have some sortable
and not sortable columns)...

TIA
Adam
MCAD

Nov 19 '05 #2
Hi Eliyahu,

I don't use autogenereted columns ;))

Maybe I should say it more cleary. When you call DataBind on DataGrid,
it builds etire control from information stored in template objects.
Usually you call DataBind in OnLoad handler or in same postback event
handlers. That means that your grid (or martix of controls) is already
created in PreRender. I can't set DataGrid1.HeaderText = "MyHeader" in
PreRender because this is a template property and such change dosn't
affect.

I'd like to change my datagrid's headers according to launguage in
dropdownlist (autopostback). I can do it only in prerender handler (I
have a base class for all my datagrids). I can find header cells walking
through Controls (DataGrid.Controls[0].Controls[0] etc.) but I can't set
any Id to easy recognize "my" headers.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3
If DataGrid1.HeaderText = "MyHeader" doesn't effect in PreRender, what
about ItemDataBound event?

Eliyahu

"Adam Boczek" <ad*********@gmx.de> wrote in message
news:O8*************@TK2MSFTNGP09.phx.gbl...
Hi Eliyahu,

I don't use autogenereted columns ;))

Maybe I should say it more cleary. When you call DataBind on DataGrid,
it builds etire control from information stored in template objects.
Usually you call DataBind in OnLoad handler or in same postback event
handlers. That means that your grid (or martix of controls) is already
created in PreRender. I can't set DataGrid1.HeaderText = "MyHeader" in
PreRender because this is a template property and such change dosn't
affect.

I'd like to change my datagrid's headers according to launguage in
dropdownlist (autopostback). I can do it only in prerender handler (I
have a base class for all my datagrids). I can find header cells walking
through Controls (DataGrid.Controls[0].Controls[0] etc.) but I can't set
any Id to easy recognize "my" headers.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #4
ItemDataBound is triggered during data binding so you can't tell "when" it
fires. I'd like to change language on page using dropdownlist control (with
languages "supported" by page). That change will be first present in
dropdownlist change eventhandler and than I can set CurrentUICulture to
choosen language. All easy controls (ButtonLink etc.) are not "ready" until
prerender, so I can change any proprety like "text" of such control in
prerender without problems. Template controls are "ready" in prerender and
that's my problem :(

Adam

"Eliyahu Goldin" <re*************@monarchmed.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP14.phx.gbl...
If DataGrid1.HeaderText = "MyHeader" doesn't effect in PreRender, what
about ItemDataBound event?

Eliyahu

"Adam Boczek" <ad*********@gmx.de> wrote in message
news:O8*************@TK2MSFTNGP09.phx.gbl...
Hi Eliyahu,

I don't use autogenereted columns ;))

Maybe I should say it more cleary. When you call DataBind on DataGrid,
it builds etire control from information stored in template objects.
Usually you call DataBind in OnLoad handler or in same postback event
handlers. That means that your grid (or martix of controls) is already
created in PreRender. I can't set DataGrid1.HeaderText = "MyHeader" in
PreRender because this is a template property and such change dosn't
affect.

I'd like to change my datagrid's headers according to launguage in
dropdownlist (autopostback). I can do it only in prerender handler (I
have a base class for all my datagrids). I can find header cells walking
through Controls (DataGrid.Controls[0].Controls[0] etc.) but I can't set
any Id to easy recognize "my" headers.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 19 '05 #5

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

Similar topics

1
by: Webgour | last post by:
Hi, I'm tring to add a column to a datagrid with a linkbutton as header that can be used to sort the column. The column and the linkbutton are added programmatically (see below). However the...
6
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
2
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns,...
1
by: Chris | last post by:
Is there a way to autosize the Datagrid column widths to just a bit larger than the data. I know how to manually size the column in code but I have a dynamically created datagrid and it work...
9
by: Roy | last post by:
Hey all, On my html page I have a datagrid with the column: <boundColumn datafield="xyz" visible = false> </boundColumn> In my code behind, within item data bound event, I dynamically set the...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
1
by: nate axtell | last post by:
I'm trying to extend the Height of Windows.Forms Datagrid's column headers. Is it possible to allow wrapping of text in the header column cells along with making the height larger?
2
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.