I have a table with person data which are Name, Surname, Code and Photo of persons. And when I select persons from table like and send the result to DevExpress GridControl it shows Name, Surname and Code columns. But Photo column displays System.Byte[] value in all rows. What is the problem.
You should assign the column's ColumnEdit property with an instance of a RepositoryItemPictureEdit . In this case, the XtraGrid will be able to show image in the grid.
Sample: How to display an image in GridControl
Related links:
***Byte Convert To Image
data.Read();
//get the value of the size field in the current row and store it in filesize
int fileSize = data.GetInt32(data.GetOrdinal("size"));
//get the value of the name field in the current row and store it in filesize
string name = data.GetString(data.GetOrdinal("name"));
//Create a byte array to read the file in the row which is in bytes
byte[] rawData = new byte[fileSize];
//Read the bytes and store it in the array
data.GetBytes(data.GetOrdinal("file"), 0, rawData, 0, fileSize);
//Create the file from the byte array which is read from the database
FileStream fs = new FileStream(name, FileMode.Create, FileAccess.Write);
fs.Write(rawData, 0, fileSize);
//closing the file stream
fs.Close();
//Showing the image that is just retreived in te picturebox picDB
picDB.BackgroundImage = new Bitmap(name);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.