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 !




not to export gridview control to excel


Posted Date: 10 Oct 2006      Total Responses: 1

Posted By: vijay khan       Member Level: Silver     Points: 2


i want to export data to excel sheet from gridview not its edit or update or cancel control



Responses

Author: Mohan Kumar    10 Oct 2006Member Level: DiamondRating:     Points: 2
hi,

try this,

Public Sub exp(ByVal FileName As String, ByVal dg As System.Web.UI.WebControls.DataGrid)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=" + FileName)
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
dg.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString)
Response.End()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
exp("mohan.xls", DataGrid1)
End Sub

-Mohan kumar



Post Reply
You must Sign In to post a response.
Next : how to make the Column header of a Datagrid to fit to single line?
Previous : Plz solve my error
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use