Solved

Email panel containing a gridview

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

14 Experts available now in Live!

Get 1:1 Help Now