Home All Groups Group Topic Archive Search About

Prerender changes get lost after Page.RenderControl

Author
14 Jan 2006 2:21 AM
John Dalberg
I am trying to send a webpage with datagrids as an email so I use the code
snippet below. In one of my datagrids, I reformat some rows in the
datagrid's Prerender event. The code behind of the page displays the page
and sends the email. The page displays fine however the email has the same
look and everything *except* the changes that were made in the grid's
prerender. I think I am missing something and was wondering why the changes
were lost. I am thinking it's a timing issue. How can I get
Page.RenderControl() to execute the prerender event, wait till it's done
and continue to the next statement.


Code sample:
        sw = new StringWriter();
        htw = new HtmlTextWriter(sw);
        Page.RenderControl(htw);
        .
        .
        Message.Body = sw.ToString();


                private void mygrid_PreRender(object sender, EventArgs e)
                {
                  some some formating on the grid
                }

Author
13 Mar 2006 1:58 AM
cbDevelopment
Where is your code being run?  If you are executing your page code other
than in the page Prerender event, the page would not have called all its
child controls' prerender methods.  If you stpe through your code, just
breakpoint every method and see the order in which the methods run.

Or you can do it in your prerender handler for the datagrid.

--
----
700cb Development, Inc.
http://www.700cb.net
..NET utilities, developer tools,
and enterprise solutions

nospam@nospam.sss (John Dalberg) wrote in
Show quoteHide quote
news:20060113212126.521$9O@newsreader.com:

> I am trying to send a webpage with datagrids as an email so I use the
> code snippet below. In one of my datagrids, I reformat some rows in
> the datagrid's Prerender event. The code behind of the page displays
> the page and sends the email. The page displays fine however the email
> has the same look and everything *except* the changes that were made
> in the grid's prerender. I think I am missing something and was
> wondering why the changes were lost. I am thinking it's a timing
> issue. How can I get Page.RenderControl() to execute the prerender
> event, wait till it's done and continue to the next statement.
>
>
> Code sample:
>         sw = new StringWriter();
>         htw = new HtmlTextWriter(sw);
>         Page.RenderControl(htw);
>         .
>         .
>         Message.Body = sw.ToString();
>
>
>                 private void mygrid_PreRender(object sender, EventArgs
>                 e) {
>                   some some formating on the grid
>                 }
>

Bookmark and Share