EDN Admin
Well-known member
<span style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; text-align:left From my website, I have a button which calls a method and then generates reports to excel. the code works. The problem is that the code displays all
gridviews (there are 3) on the same tab. What code may I add to this so that when i click on the button, it will download the document but have each gridview displayed on their separate tabs. The tab names will be top 1, top 2, and top 3. So to clarify, right
now all of the gridviews are displayed on the top 1 tab, I need to make 2 more tabs (top 2 and top 3) and put gridview2 on top 2 tab, and gridview3 on the top 3 tab.
<span style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; text-align:left
<pre class="prettyprint using System;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet dataSet = new DataSet();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ISALog1ConnectionString"].ToString());
SqlCommand cmd = new SqlCommand("exec ProxyReport", conn);
cmd.CommandTimeout = 200;
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dataSet);
GridView1.DataSource = dataSet.Tables[0];
GridView1.DataBind();
GridView2.DataSource = dataSet.Tables[1];
GridView2.DataBind();
GridView3.DataSource = dataSet.Tables[2];
GridView3.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string attachment = "attachment; filename=Top 1.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
GridView2.RenderControl(htw);
GridView3.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
}[/code]
can someone give me suggestions for a newbie? this code is server sided. but i want the easiest way to make it work, third party maybe? epplus i tried but i still dont know how the code works to implement it into mine.<br/>
<span style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; text-align:left
View the full article
gridviews (there are 3) on the same tab. What code may I add to this so that when i click on the button, it will download the document but have each gridview displayed on their separate tabs. The tab names will be top 1, top 2, and top 3. So to clarify, right
now all of the gridviews are displayed on the top 1 tab, I need to make 2 more tabs (top 2 and top 3) and put gridview2 on top 2 tab, and gridview3 on the top 3 tab.
<span style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; text-align:left
<pre class="prettyprint using System;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet dataSet = new DataSet();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ISALog1ConnectionString"].ToString());
SqlCommand cmd = new SqlCommand("exec ProxyReport", conn);
cmd.CommandTimeout = 200;
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dataSet);
GridView1.DataSource = dataSet.Tables[0];
GridView1.DataBind();
GridView2.DataSource = dataSet.Tables[1];
GridView2.DataBind();
GridView3.DataSource = dataSet.Tables[2];
GridView3.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string attachment = "attachment; filename=Top 1.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
GridView2.RenderControl(htw);
GridView3.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
}[/code]
can someone give me suggestions for a newbie? this code is server sided. but i want the easiest way to make it work, third party maybe? epplus i tried but i still dont know how the code works to implement it into mine.<br/>
<span style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; text-align:left
View the full article