I send the Gridview as email body in asp.net using C#.

Everything works correctly, except that in the body of the email the Gridview is not formatted as expected, the style sheet CSS is not applied.

How to do resolve this ?

My code below, thanks in advance for any help.

markup code gridview

<asp:GridView ID="gvbody" AutoGenerateColumns="False" EmptyDataText="No data" 
    runat="server" CssClass="mGrid" HorizontalAlign="Center" 
    <AlternatingRowStyle CssClass="altrows" />
        <asp:TemplateField HeaderText="N." 
         ItemStyle-CssClass="ddl_Class_new" ItemStyle-HorizontalAlign="Center">
                <%#String.Format("{0:N0}",Container.DataItemIndex + 1)%>


public string GetGridviewData(GridView gv)
    StringBuilder strBuilder = new StringBuilder();
    StringWriter strWriter = new StringWriter(strBuilder);
    HtmlTextWriter htw = new HtmlTextWriter(strWriter);
    return strBuilder.ToString();

mailMessagePlainText.Body += GetGridviewData(gvbody);

Related posts

Recent Viewed