Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
export gridview to txt file
Niranjan Poddar
10y
627
1
Reply
Dear all,
Please tell me
how to export gridview to txt file in asp.net.
this is my code but not working
public void MakeTextFileFromGridView ( )
{
StringBuilder sb = new StringBuilder ( );
for ( int i = 0; i <= grdForm4A.Rows.Count-1; i++ )
{
for ( int j = 0; j <= grdForm4A.Columns.Count-1; j++ )
{
sb.Append ( grdForm4A.Rows[i].Cells[j].ToString ( ) );
}
sb.Append ( "<br/>" );
}
Response.Clear ( );
Response.AddHeader ( "content-disposition",
"attachment;filename=FileName.txt" );
Response.Charset = "";
Response.Cache.SetCacheability ( HttpCacheability.NoCache );
Response.ContentType = "application/vnd.text";
System.IO.StringWriter stringWrite = new System.IO.StringWriter ( );
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter ( stringWrite );
Response.Write ( sb.ToString ( ) );
Response.End ( );
}
Thanks in adv.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
how we can increase and decrease financial year value
Redirect Querystring