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

Image Control not refreshing after update in database Problem!!!!

3 Answers 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asa'ad
Top achievements
Rank 1
Asa'ad asked on 25 Sep 2011, 10:12 AM
Hi All,

Kindly i have  Contacts RadGrid, one of the columns is A template which has Image control to show contact photo saved in the database as Binary....

while binding data to this grid i use the following code to set the image url propertry,

imageControl.ImageURL = "~/ShowContactPhoto.ashx?ContactID=10";

and this is the code in this page:

 

 

 

public class ShowContactPhoto : IHttpHandler
  
{
  
public void ProcessRequest(HttpContext context)
  
{
  
  
int iContactID = Convert.ToInt32(context.Request.QueryString["ContactID"]);
  
Stream strm = showContactImage(iContactID);
  
byte[] buffer = new byte[4096];
  
int byteSeq = strm.Read(buffer, 0, 4096);
  
while (byteSeq > 0)
  
{
  
context.Response.OutputStream.Write(buffer, 0, byteSeq);
  
byteSeq = strm.Read(buffer, 0, 4096);
  
}
  
  
}
  
public Stream showContactImage(int iContactID)
  
{
  
Individual_Contacts_BLL bllContact = new Individual_Contacts_BLL();
  
Individual_Contacts_BO boContact = new Individual_Contacts_BO();
  
boContact.Contact_ID = iContactID;
  
DataTable dt = bllContact.selectContactPhoto(ref boContact);
  
object img = dt.Rows[0]["Contact_Photo"];
  
try
  
{
  
return new MemoryStream((byte[])img);
  
}
  
catch
  
{
  
return null;
  
}
  
// return null;
  
}
  
public bool IsReusable
  
{
  
get
  
{
  
return false;
  
}
  
}
  
}

Also, user can edit contact information, and also in the photo, i do the edit in another page opened in a Radwindow....all is fine and all the data is updated in database even the image, i call the grid rebind via an ajax request and also the grud is refreshed...BUT, neither the image control in the edit window page and the cloumn in the radgrid is refreshed until i call the page again!!!!

i debug the code, and the ImageURL is rewritten but the ShowContactPhoto.ashx is not called again until i call the whole page which holds the grid again!!!

i tried to send a random number within the url so not called from the cash,,, but still not called!!!

how can i acheive this, i need to show the updated image in the edit window and the grid without the need  to call the page again!!!

any help will be geat...
thanks
asa'ad

 

3 Answers, 1 is accepted

Sort by
0
Asa'ad
Top achievements
Rank 1
answered on 27 Sep 2011, 07:16 AM
any comment? please help!!!!
0
Accepted
Iana Tsolova
Telerik team
answered on 28 Sep 2011, 11:11 AM
Hello Asa'ad,

You can use our RadBinaryImage control. Check the below demos:
http://demos.telerik.com/aspnet-ajax/binaryimage/examples/default/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=binaryimage
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandradasyncupload/defaultcs.aspx?product=binaryimage
 

Kind regards,
Iana Tsolova
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
0
Asa'ad
Top achievements
Rank 1
answered on 29 Sep 2011, 07:11 AM
Hi lana,,,

thanks for the links....
the RadBinaryImage realy solved my problem in the Grid and the update page window....

thank you again...

Best Regards
Asa'ad
Tags
Grid
Asked by
Asa'ad
Top achievements
Rank 1
Answers by
Asa'ad
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or