ziad mansour
ziad mansour

Reputation: 349

Get an array of bytes from a datagridview

I have a datagridview that are connected to a table in SQL database. There is a column of type VARBINARY(MAX) that store a sequence of bytes. How can I extract these bytes from the grid view?

my code is:

byte [] a = datagridview.CurrentRow.Cells[4].Value;

in which cell[4] contain the bytes.

but it gives an error:

cannot implicitly convert type Object To byte[]

Upvotes: 1

Views: 2812

Answers (1)

Lismore
Lismore

Reputation: 263

Try casting the right hand side like this

byte [] a = (byte [])datagridview.CurrentRow.Cells[4].Value;

Upvotes: 1

Related Questions