TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Niranjan Poddar
1.1k
648
95.9k
export gridview to txt file
Sep 2 2014 2:25 AM
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.
Reply
Answers (
2
)
how we can increase and decrease financial year value
Need to get Computer name When site hosted on server