C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Records from Datagrid to Excel sheet


Posted Date: 22 Aug 2008    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Ramesh NarayanMember Level: Gold    
Rating: 1 out of 5Points: 7



This section shows how to export records from Datagrid to Excel sheet in WebApplication.


protected void Page_Load(object sender, EventArgs e)
{
dbcon = new DbConnection();
sqlcon = new SqlConnection();
sqlcon = dbcon.databaseconnection();
sqlcon.Open();
ds = new DataSet();
sqladap = new SqlDataAdapter(str_Query, sqlcon);
sqladap.Fill(ds, "TableName");
}

protected void Button1_Click(object sender, EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(stringWriter);
DataGrid1.RenderControl(htmlWriter);
Response.Write(stringWriter.ToString());
Response.End();
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Records from Datagrid to Excel sheet  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: AJAX with XMLHttpRequest Object
Previous Resource: How to open word,excel file on a new web page
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use