views:

69

answers:

1

I'm passing a datebase reader object to a DataGrid and it sees one of my columns as type byte[] but I happen to known that it should always be a printable string. How can I force the .NET DateBinding system to do that conversion? The only place I can see to put anything is in BoundColumn.DataFormatString but I can't find any indication how to do what I need with that.


Edit: I known how to convert a byte[] to a string in general but don't know how make the BoundColumn do it.

Because in this case I can edit the query string, I hacked passed it by using PADR(column,0) as column in the SELECT. I'm still interested in what to do if I couldn't modify the query.

A: 

You can use System.Text.Encoding.UTF8.GetString(byte[]) to get the string (make sure you use the correct encoding where UTF8 is present - there is ASCII, UTF7, UTF8, Unicode, and UTF32).

Rex M
See edit
BCS