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
Geetha Mouli
NA
2
0
Problem in exporting grid view to excel file
Jun 15 2010 4:34 AM
Hi,
I have export to excel option for all my reports. In few of report, if i export to excel file the file just has 'No records found' the text which i have mensioned in
<
EmptyDataTemplate
>
In few other reports i am not getting the proper value or proper format. I don't have any clue why it is happening like that.
Here is my code.
.aspx file
<
asp
:
GridView
ID
="GridView1"
runat
="server"
CssClass
="txt"
AlternatingRowStyle-BorderStyle
="Ridge"
BorderStyle
="Ridge"
CellSpacing
="2"
BorderColor
="#333333"
CellPadding
="2">
<
EmptyDataTemplate
>
No records found.
</
EmptyDataTemplate
>
</
asp
:
GridView
>
.vb page
On page load...
Dim
strQuery
As
String
=
"SELECT Gate, COUNT(TicketInfo) AS 'People Entered' FROM tbl_access_info"
Dim
cmd
As
SqlCommand
=
New
SqlCommand
(strQuery,
New
SqlConnection
(strConnectionString))
cmd.Connection.Open()
GridView1.DataSource = cmd.ExecuteReader()
GridView1.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
Private
Sub
ExportToExcel(
ByVal
strFileName
As
String
,
ByVal
dg
As
GridView
)
Response.Clear()
Response.Buffer =
True
Response.ContentType =
"application/vnd.ms-excel"
Response.Charset =
""
Me
.EnableViewState =
False
Dim
oStringWriter
As
New
System.IO.
StringWriter
Dim
oHtmlTextWriter
As
New
System.Web.UI.
HtmlTextWriter
(oStringWriter)
GridView1.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.[End]()
End
Sub
Can u help me to identify the problem? Thanks in advance.
Geetha
Reply
Answers (
0
)
Select Sheet in VB dot net
How to add hot key function to my TextBox