Actually when i was removing template field in code behind and again i was binding but grid was losing its data source
So i removed the template Field and than re-binned that grid view whose data source was in View state
my code is as follows in
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
viewstate("GVsearch") = GVDetails.datasource
GVDetails.Columns.RemoveAt(0)
dtCurrentTable = ViewState("GVSearch")
GVDetails.DataSource = dtCurrentTable
GVDetails.DataBind()
Dim ReportName As String = ""
ReportName = ddlReportFor.SelectedItem.Text
ReportName = "VPO_Report_" & Format(Now, "yyyy_MM_dd_HH_mm_ss")
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" & ReportName & ".xls")
'HttpContext.Current.Response.ContentEncoding = Encoding.UTF8
Dim tw As New StringWriter()
Dim hw As New HtmlTextWriter(tw)
'tbl1.RenderControl(hw)
'TPOOutPut.RenderControl(hw)
Dim frm As HtmlForm
frm = New HtmlForm
frm.Attributes("runat") = "server"
frm.Controls.Add(GVDetails)
'GVDetails.Parent.Controls.Add(frm)
'frm.RenderControl(hw)
GVDetails.RenderControl(hw)
HttpContext.Current.Response.Write(tw.ToString())
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.[End]()
End Sub</pre>
And Thanks for your support every one