This is a migrated thread and some comments may be shown as answers.

loading image directory

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Toboy
Top achievements
Rank 1
Toboy asked on 05 Mar 2012, 03:37 PM
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 ();
           
 
           
       }

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 08 Mar 2012, 10:37 AM
Hello,

The presented code looks correct to me and there is nothing obvious that may cause the problematic behaviour.
Could you please elaborate a bit more on your application. By saying it was working before, do you mean that the application has worked correctly with previous versions f the control. If this is the problem could I kindly ask you to open a regular support ticket and send us sample runnable application which demonstrates the described issue. Thus we will be able to test it locally and advise you further.

Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Toboy
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or