Solved

Email panel containing a gridview

Posted on 2008-06-11
3
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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