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()
|