C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Records from Datagrid to Excel sheet


Posted Date: 22 Aug 2008    Resource Type: Articles    Category: Web Applications

Posted By: Ramesh Narayan       Member Level: Gold
Rating:     Points: 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  
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: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use