I have two RadGrid on a page when I select any row of the first RadGrid it shows the details in the second RadGrid where it also carries the product image is everything perfect except that when I have the image of the product I pointed to a directory where he carried a picture product is not available as I make my old code he was working this way:
foreach
(DataRow ors
in
ds.Tables[0].Rows)
{
if
(ds.Tables[0].Rows[0][
"Bytes"
].ToString().Trim() !=
string
.Empty)
myfoto = (
byte
[])ors[0];
}
//Caso o produto não tenha foto é atribuído uma imagem
//com o texto "Foto não disponível"
if
(ds.Tables[0].Rows[0][
"Bytes"
].ToString() ==
string
.Empty)
{
//Colocar i caminho da imagem
string
FinalPath = @
"C:\Users\Administrador\documents\visual studio 2010\Projects\site uniao\site uniao\imagens\fotonaodisponiel.gif"
;
FileStream stream =
new
FileStream(FinalPath, FileMode.Open, FileAccess.Read);
BinaryReader reader =
new
BinaryReader(stream);
myfoto = reader.ReadBytes((
int
)stream.Length);
}
context.Response.ContentType =
"Bytes/JPG"
;
context.Response.BinaryWrite(myfoto);
this is my main code of the RadGrid :
private
void
pesquisar()
{
SqlConnection conn =
new
SqlConnection(@
"Data Source=INFORMATICA005;Initial Catalog=unibanco;Integrated Security=True"
);
SqlCommand comm = conn.CreateCommand();
comm.CommandText =
"SELECT * FROM uniao "
;
string
[] palavras = RadTextBox2.Text.Split(
' '
);
string
sep =
"where descricao like"
;
int
cont = 0;
foreach
(
string
s
in
palavras)
{
comm.CommandText += sep +
" @palavra"
+ cont.ToString();
comm.Parameters.AddWithValue(
"@palavra"
+ cont.ToString(),
"%"
+ s +
"%"
);
sep =
" AND descricao like"
;
cont++;
}
SqlDataAdapter da =
new
SqlDataAdapter(comm);
DataTable ds =
new
DataTable ();
da.Fill(ds);
Session[
"gridtable"
] = ds;
RadGrid1.DataSource = Session[
"gridtable"
];
RadGrid1.Rebind ();
}