Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I export a Gridview Control to Excel in DotNetNuke?
    text
    copied!<p>Is there an alternative to using this since using a <code>&lt;form runat="server"&gt;</code> will cause a 500 error.</p> <pre><code>public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ } </code></pre> <p><em><strong>EDITED</strong></em></p> <p>With the assistance from @HansDerks I ended up using the following(a jazzed up version of the solution provided.):</p> <pre><code>protected void Export_Click(object sender, System.EventArgs e) { StringWriter writer = new StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); GridView gridView = new GridView(); gridView.DataSource = MySqlDataSource; gridView.AutoGenerateColumns = true; gridView.DataBind(); gridView.HeaderRow.Style.Add("background-color", "#003c74"); gridView.HeaderRow.Style.Add("color", "#ffffff"); for (int i = 0; i &lt; gridView.Rows.Count; i++) { GridViewRow row = gridView.Rows[i]; //Change Color back to white row.BackColor = System.Drawing.Color.White; //Apply text style to each Row row.Attributes.Add("class", "textmode"); //Apply style to Individual Cells of Alternating Row if (i % 2 != 0) { row.BackColor = System.Drawing.Color.AliceBlue; } } gridView.RenderControl(htmlWriter); htmlWriter.Close(); Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=filename.xls"); Response.Charset = ""; Response.Write(writer.ToString()); Response.End(); } </code></pre> <p>I hope you guys will find it useful. Thanks everyone!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload