Fixing Funny Characters When Exporting Data to Excel September 30 2005
There are two quirks that I came across when exporting data to excel from a data source.
1. Registration marks such as ® came with additional characters attached to them.
Fix: Change the encoding of the response to UTF-7
Response.ContentEncoding = System.Text.Encoding.UTF7
2. Data that had less-than symbols “<” could not permit any of the data after the symbol to be rendered
Fix: Replace data going in with the HTML equivalent
strMyData = strMyData.replace(”
Programmatically Setting the Header and Footer Text of a Datagrid
Suppose you wish to create a datagrid programmatically such as:
…
Dim dg as new DataGrid
…
The usual method of binding existing data to this grid is like:
…
dg.datasource = dvMyDataView
dg.databind
…
I have come across the need to add footer data to the datagrid however I first tried to inject the row with my values.
The key to header and footer data at runtime in .NET is column declarations!
When you create a datagrid by hand, create each column individually such as:
…
Dim datagridcol As New BoundColumn
datagridcol.HeaderText = “Market”
datagridcol.DataField = “Application”
…
Manipulating Datagrid Data at Runtime September 29 2005
This is by no means an official way to do things, this is a way to trick the result of a datagrid into displaying manipulated cell data.
The general theory is to hide the cell that you want to maniupulate the data of (at runtime) and replace it with a new cell containing the manipulated data.
1. First we need to use the ItemDataBound event for a datagrid. This will allow us to change data at runtime
Sub dgResults_OnDataBind( _
ByVal sender As System.Object, _
…
Windows SP2 and blocking IIS on Port 80 September 26 2005
I had the pleasure of installing Windows XP SP2 this morning only to find my security settings blocking port 80 on my webserver!
Curse.
Here is the fix….looks like SP2 installs a personal firewall.
> cmd
> Wscui.cpl
How to create PDFs from ASP.NET September 20 2005
I’m currently involved in a project where one of the functional requirements is to allow users to print documents without having the annoying web address bar on the footer of every page. This seems to be an impossible task since printing is handled by the client application (browser + window.print()) which the server has no control over.
An alternate method of achieving this was to create PDFs on the fly from the database data. After much searching I found what appears to be the holy grail for such a task. There is a library suite called iTextSharp. …
| older posts »