On my aspx page I have a datalist where I'm pulling the Area and Doc_name.
<asp:DataList ID="DataList2" runat="server"
DataSourceID="AreaName" ToolTip="Area" style="font-weight: 700" Width="404px">
<ItemTemplate> Area
<asp:Label ID="Label1" runat="server" Text='<%# Eval("area") %>'></asp:Label> -
<asp:Label ID="Label2" runat="server" Text='<%# Eval("doc_name") %>'></asp:Label>
</ItemTemplate> </asp:DataList>
So when I export to excel I want Area and doc_name to come up
in the caption. Is that possible?
So instead of the caption below that's bold I want the Area and doc_name to come up:
Protected Sub BtnExportExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
'Label1.Text = Request.QueryString("Area")
'Label2.Text = Request.QueryString("doc_name") Response.Clear()
response.Buffer = True
response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.AddHeader("content-disposition", "attachment;filename=Projects.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False Dim sw As New IO.StringWriter()
Dim hw As New HtmlTextWriter(sw) GridView1.AllowPaging = False
GridView1.DataBind()
'adding spaces to the left and right of the title
GridView1.Caption = "T16 DI Area Pending Claims Listings " GridView1.HeaderRow.Attributes.Add("style", "font-size:10px")
For i As Integer = 0 To GridView1.HeaderRow.Cells.Count - 1
GridView1.HeaderRow.Cells(i).Style.Add("background-color", "#B43636")
Next For i As Integer = 0 To GridView1.Rows.Count - 1
Dim row As GridViewRow = GridView1.Rows(i)
'Change Color back to white
row.BackColor = System.Drawing.Color.White
'Apply text style to each Row
row.Attributes.Add("class", "text") Next
Me.RemoveControls(GridView1) GridView1.RenderControl(hw)
'Dim style As String = "<style> .textmode { mso-number-format:\@; text-wrap; } </style>"
'Response.Write(style)
' set content type and character set to cope with european chars like the umlaut.
Response.Write("<meta http-equiv=Content-Type content=""text/html; charset=utf-8"">" & vbLf)
' add the style props to get the page orientation
Response.Write(AddExcelStyling())
'Response.Write(String.Format("Label1 text = '{0}'", Label1.Text))
'Response.Write(String.Format("Label2 text = '{0}'", Label2.Text))
Response.Write(sw.ToString()) Response.Flush()
Response.Write("</body>") Response.Write("</html>")
Response.[End]() End Sub