Solved

Email panel containing a gridview

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now