Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2004, 02:18 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default triming '0' while exporting to excel from datagrid

 Hi I am doint export to excel from my datagrid
in my sql qury i have one fld called transno datatype nvarchar
data for this transno col like 'A90','0123' ect

when i do the export the excel sheet showing data for col transno like this
'A90','123'

i think its exporting in number format so that its triming the '0' in my '0123'
so how to avoid this problem?pl help me.

       Response.Clear()
        Response.Charset = ""
        Response.ContentType = "application/vnd.ms-excel" ' set the content type
        Response.AddHeader("Content-Disposition", " attachment; filename=urreportname.xls")
        Dim stringWrite As New System.IO.StringWriter
        Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
        Dim dg As New System.Web.UI.WebControls.DataGrid
        dg.DataSource = myDataSet.Tables(0) ' it is here where u need to assign ur datatable
        dg.DataBind()

        dg.RenderControl(htmlWrite)
        Response.Write(stringWrite.ToString)
        Response.End()








Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting data from datagrid to excel??? twyce C# 3 March 4th, 2010 04:51 AM
exporting to excel from datagrid hotshot_21 ASP.NET 1.0 and 1.1 Basics 2 June 9th, 2006 08:53 AM
problem in exporting datagrid to excel swati_joshi ASP.NET 1.0 and 1.1 Professional 3 June 4th, 2006 11:26 PM
problem exporting datagrid to excel kscdave Classic ASP Professional 0 March 29th, 2005 11:57 AM
Exporting DataGrid To Excel chiefg C# 2 December 31st, 2003 12:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.