Solved

Email panel containing a gridview

Posted on 2008-06-11
3
266 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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