Sending DataGrid in Email via ASP.NET

Results 1 to 2 of 2

Thread: Sending DataGrid in Email via ASP.NET

  1. #1
    Join Date
    Dec 1969

    Default Sending DataGrid in Email via ASP.NET

    Hi,<BR>I am getting an error trying to send a datagrid via email. I was using the article in 4guys at: <BR>My code is:<BR> Sub ExportMail()<BR> Dim sb As New System.Text.StringBuilder()<BR> Dim sw As New System.IO.StringWriter(sb)<BR> Dim htw As New System.Web.UI.HtmlTextWriter(sw)<BR> DispReport.RenderControl(htw)<BR> Dim dataGridHTML As String = sb.ToString()<BR> Dim objMM As New Mail.MailMessage()<BR> objMM.To = ""<BR> objMM.From = ""<BR> objMM.BodyFormat = Mail.MailFormat.Html<BR> objMM.Body = dataGridHTML<BR> End Sub<BR><BR>It errors at the line: DispReport.RenderControl(htw) where DispReport is a datagrid. The error is:<BR><BR>System.Web.HttpException: Control &#039;DispReport__ctl1__ctl0&#039; of type &#039;DataGridLinkButton&#039; must be placed inside a form tag with runat=server.<BR><BR>Does this render method not allow a linkbutton? My DataGrid has sort buttons on it. I think that is where it is erroring. Any ideas?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Sending DataGrid in Email via ASP.NET

    You need to do just like the error says to do. Wrap your code in a &#060;form runat="server"&#062;&#060;/form&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts