Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
I want to save the contents of gridview to the excel file and i am using the following code to done ...
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
AMOL
12y
1.9k
1
Reply
protected void SaveBtn_Click(object sender, EventArgs e)
{
try
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Response.AddHeader("content-disposition", "attachment; filename=" + DropDownList1.SelectedItem.Text + "_" + DropDownList2.SelectedItem.Text + "_" + DropDownList3.SelectedItem.Text + "_" + TextBox1.Text + ".xls");
Response.ClearContent();
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.Flush();
Response.End();
}
catch (Exception ex)
{
}
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
datagrid checkbox
How can i implement a functionality (affliated ads)in asp.net website?