473,750 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6204
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*********@gm x.de> wrote in message
news:uz******** ******@TK2MSFTN GP09.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.Heade rText = "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.Contr ols[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.Heade rText = "MyHeader" doesn't effect in PreRender, what
about ItemDataBound event?

Eliyahu

"Adam Boczek" <ad*********@gm x.de> wrote in message
news:O8******** *****@TK2MSFTNG P09.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.Heade rText = "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.Contr ols[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 CurrentUICultur e 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.co m> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
If DataGrid1.Heade rText = "MyHeader" doesn't effect in PreRender, what
about ItemDataBound event?

Eliyahu

"Adam Boczek" <ad*********@gm x.de> wrote in message
news:O8******** *****@TK2MSFTNG P09.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.Heade rText = "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.Contr ols[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
8907
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 problem is that when you click the added column header it doesn't trigger the sort. The code : <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
6
3248
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 entry application. The code below gets line items from a SQL Server database and returns them to a datagrid by way of a DataTable called lineTable. As long as I am just displaying columns in the SQL database everything works well. I now want...
2
2113
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, ID and VALUE. I would like to create a templated column in the datagrid that is bound to the VALUE column of the datasource.
1
1511
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 except the data is all squeezed together. I'd like a way to measure the text in the column and then increase the size a little so it's easier to read. Thanks Chris
9
6465
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 column text like so: e.item.cells(10).text = mystring.trim
8
2266
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 happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
4
2011
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, when the datagrid enters it's own OnPreRender, the selected index has reverted to zero. I created a debug version of the dropdown list which inherited from dropdownlist and overrode the selected index property to trace.write whenever it was...
1
3647
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
2710
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 handles the event gets called, however when it is unchecked, it does not fire. Is this by design, or is something else that is going on? Thanks!!. This message was originally posted by marian@discussions.microsoft.com, but
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9394
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9338
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
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
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.