Click to See Complete Forum and Search --> : System.Byte[] problem


xxsoulxx
January 31st, 2006, 01:09 AM
hi there , whenever i try retrieve a file from my db it always displays System.Byte[] in the datagrid .. how do i display the whole file .. ?

ITGURU
January 31st, 2006, 04:29 AM
Dear xxsoulxx,

You can place file into Data Grid. To achieve this functionality you have to follow following step:
1. Place a Label in the Item Template of the Datagrid e.g. its name is lblFile.
2. Set DataSource of the Data Grid as DataSet which you generated from DB.
3. Add a OnItemDataBound Event for the Data Grid in Code Behind File
4. Write code into OnItemDataBound event of the Data Grid as per following psuedo code:


if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Label lblFile = (Label)e.Item.FindControl("lblFile");
// yourFileString variable contains the contents of the File which readed from DB.");
lblFile.Text = yourFileString;

}

mmetzger
January 31st, 2006, 10:13 AM
You're assuming that the file is text. The basic idea is correct, but you'll need to add a handler to properly format the file into whatever it may be (image, binary, etc.) If it's anything other than an image file, you'll likely need to add a special page to retrieve that data by itself and add a link via the method ITGURU is speaking about.

xxsoulxx
January 31st, 2006, 02:41 PM
sorry for asking about your post ..

Dear xxsoulxx,

You can place file into Data Grid. To achieve this functionality you have to follow following step:
1. Place a Label in the Item Template of the Datagrid e.g. its name is lblFile.
---( can tell me where about is this ?? )---


hmm do u have examples on retrieving a mp3 file stored in the ms access and displaying ?