Solved

Email panel containing a gridview

Posted on 2008-06-11
3
269 Views
Last Modified: 2010-04-21
Hello, I'm using the code below to email the contents of a panel which contains some labels and a gridview.

I get the following error on this line : pnlMyCart.RenderControl(htmlTW)

Error:
Control 'gvMyCart' of type 'GridView' must be placed inside a form tag with runat=server.

The Page does contain a form tag and the gridview that resides in the panel is in that form tag. how can I get this to work?


 Dim SB As New StringBuilder()
        Dim SW As New StringWriter(SB)
        Dim htmlTW As New HtmlTextWriter(SW)
        pnlMyCart.RenderControl(htmlTW)
        Dim panel1HTML As String = SB.ToString()
        ltlemmsg.Text = Server.HtmlDecode(panel1HTML)

        Dim MailObj As New MailMessage

        MailObj.From = New MailAddress("NoReply@mecom")
        MailObj.To.Add("Scott@me.com")
        MailObj.Subject = ("me Purchase")
        MailObj.Body = ltlemmsg.Text

        MailObj.IsBodyHtml = True

        Dim smtp As New SmtpClient("exchange.me.com")
        smtp.Send(MailObj)
0
Comment
Question by:gogetsome
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 21764105
When you use this method, you can't render any control that would normally cause a postback.  What you need to do is render a "Dumbed" down version of the Gridview that is data only!  e.g. Disable sorting, hide that button column, no paging, etc.!
0
 
LVL 33

Expert Comment

by:raterus
ID: 21764115
This article contains a lot of good advice about what you're doing, and it has some alternative methods as well.

http://aspnet.4guysfromrolla.com/demos/printPage.aspx?path=/articles/102203-1.aspx
0
 

Author Closing Comment

by:gogetsome
ID: 31466339
Yes, this is true.. sorry forgot this tidbit of info.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question