Hi All,
Now i have changed the datagrid to display only text name of competencie.Heres the code below for datagrid.
<asp:datagrid id="lstexport" AutoGenerateColumns="false" width="600px" DataKeyField="CompetencyId"AllowSorting="false" CellPadding="4" GridLines="none" cssclass="DataGrid_Container" runat="server" AllowPaging="false">
<columns>
<asp:TemplateColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
<itemtemplate>
<asp:label ID="Label11" runat="server" text='<%# DataBinder.Eval(Container.DataItem,"CompetencyName") %>' Height="20" ></asp:label>
</ItemTemplate>
</asp:TemplateColumn>
</columns>
</ASP:DATAGRID>
And the back end file function is as follows i mean the vb code.On clicking on the menu item it will display a panel which contains the above grid
Sub displayexport()
Dim Competencylist As List(Of CompetencyInfo)
Competencylist = CompetencyController.sampleexport()
If Competencylist.Count > 0 Then
lstexport.DataSource = Competencylist
lstexport.DataBind()
pnlexport.Visible = True
Else
pnlCompetencies.Visible = False
End If
End Sub
And in the grid theres a link export to excel at the bottom which has the following function
Protected Sub lnkexport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkexport.Click' Set the content type to Excel
Response.Clear()
Response.AddHeader(Response.Charset = "content-disposition", "attachment;filename=myexcelfile.xls")
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.ContentType = "application/vnd.xls"
htmlWrite.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Html)
Dim StringWriter As New StringWriterDim htmlWrite As New HtmlTextWriter(StringWriter)True
lstexport.GridLines = GridLines.Both
lstexport.AllowPaging = False
lstexport.AllowSorting = False
Render(htmlWrite)
lstexport.RenderControl(htmlWrite)
htmlWrite.RenderEndTag()
Response.Write(StringWriter)
Response.End()
End Sub
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)If Not (Page Is Nothing) Then
Page.VerifyRenderingInServerForm(lstexport)
MyBase.Render(writer)
End Sub
End If
So when i remove this render control function and execute i get the following error in a javascript popup and nothing happens.All my function goes through fine when i debug the code and after that i get this popup with the error
Sys.WebForms.PageRequestManagerParserErrorException Message recieved from the server could not be parsed.Common causes for this error are when a response is modfied by calls to Response.Write(),Response filters,Http Modules or server trace is enabled.etc...
and when i uncomment the render function i get the following error near the line Page.VerifyRenderingInServerForm(lstexport) in the render function
Control 'dnn_ctr386_Competency_lstexport' of type 'DataGrid' must be placed inside a form tag with runat=server.
Please can somebody help regarding this.I am really out of clues now.and need it urgently
Thanks,
Sandeep