dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersA'zlina
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

Excelsheet


Posted Date: 13 Dec 2007      Posted By:: Sunil Reddy     Member Level: Silver    Member Rank: 2676     Points: 2   Responses: 2



THis code is giving Error :OBject reference is not set to an instance of an object
Dim objDS As New DataSet
Dim objDT As New DataTable

'Create a dataset as required
objDT = objDS.Tables(0)
objDT.Columns("Employee_Name").ColumnName = "Employee"
objDT.Columns("Customer_Name").ColumnName = "Customer"
objDT.Columns("Visit_Count").ColumnName = "Visit Count"
Dim stwWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim htwWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(stwWriter)
Dim dgGrid As DataGrid = New DataGrid
dgGrid.DataSource = objDS
dgGrid.HeaderStyle.Font.Bold = True
dgGrid.Width.Percentage(100)
dgGrid.DataBind()
dgGrid.RenderControl(htwWriter)
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Response.Write(stwWriter.ToString)
Response.End()







Responses

#169557    Author: KVGaneshBabu      Member Level: Gold      Member Rank: 128     Date: 13/Dec/2007   Rating: 2 out of 52 out of 5     Points: 2

Cause that you are passing value would be null. Check passing values as without null or "";

Regards,
KVGaneshBabu



 
#169668    Author: VASANTH R      Member Level: Gold      Member Rank: 309     Date: 13/Dec/2007   Rating: 2 out of 52 out of 5     Points: 2

'Create a dataset as required
objDT = objDS.Tables(0)
objDT.Columns("Employee_Name").ColumnName = "Employee"
objDT.Columns("Customer_Name").ColumnName = "Customer"
objDT.Columns("Visit_Count").ColumnName = "Visit Count"


this is the not right way to create a datatable
first Create datacolumns and add it dt
Then add the dt to dataset

Regards,
R.Vasanth



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : How to transfer one page data onto another page without using viewstate,session,cookies in asp.net
Previous : datagrid
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.