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

Changing DetailsView controls in PreRender will fails on postbacks

Hi guys,

i'm trying to change all of page control's (root controls and inner
controls) forecolor in PreRender event.
it works fine but when a postback occures by detailsview command
buttons, it fails...

(i trace the code, it even executes in postbacks but control's
forecolor don't change)

i use this code :

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. protected override void OnPreRender(EventArgs e)
  4. {
  5. ChangeColor(this.Controls);
  6.  
  7. base.OnPreRender(e);
  8.  
  9. }
  10.  
  11.  
  12. private void ChangeColor(ControlCollection controls)
  13. {
  14.  
  15. foreach (Control c in controls)
  16. {
  17. if (c.HasControls())
  18. ChangeColor(c.Controls);
  19. else if (c is DetailsView)
  20. {
  21. DetailsView view = c as DetailsView;
  22. foreach (DetailsViewRow row in view.Rows)
  23. {
  24. ChangeColor(row.Controls);
  25. }
  26. }
  27. else
  28. {
  29. if (c is WebControl) ((WebControl)c).ForeColor =
  30. System.Drawing.Color.DeepPink;
  31. }
  32.  
  33. }
  34. }
  35.  
  36.  
Thanks

Jul 11 '07 #1
1 2346
Any Idea ??

Jul 13 '07 #2

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

Similar topics

6
by: foldface | last post by:
Hi If I add a UserControl to a placeholder on a page during that pages PreRender stage and press a button on that UserControl will the postback for that button get processed? I would have thought...
4
by: Tom Wisnowski | last post by:
Hello all, Here is a simple example of what I'm doing... Create a ASPX page Add a PlaceHolder(plch) and a Button(btn) to the page. In the code behind on Page_load add the following......
3
by: John | last post by:
I have an asp.net control which on the first Load of the page has a unique ID something like: _ctl0__ctl1_GroupName__ctl1_ControlName and after the first postback it changes to: ...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
1
by: sck10 | last post by:
Hello, I am trying to change a value when a user goes into edit mode on a DetailsView control. I am trying to use the following, but can not figure out how to get to the bound field...
5
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example,...
2
by: sck10 | last post by:
Hello, I am trying to programically make the following TemplateField ("MyTemplate") visible when the user clicks on the "Edit" Button using the PreRender handle event. My question is, how do...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
0
by: | last post by:
I'm using a detailsview to insert a record, should be simple enough? What am I doing wrong? Thank you for your help. The user fills in all the textboxes and hits insert. I've tried every event...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.