Welcome to MSDN Blogs Sign in | Join | Help

Dynamic Data DbImage SampleUpdated

I posted a sample back in January on how to display images from databases or the file system using Dynamic Data. You can view that post HERE. I've just updated that sample to fix some bugs and add some new functionality. You can download the latest version of DbImage from this link: DOWNLOAD DBIMAGE.

Here is a list of the changes and updates I've made since the original post:

1) Fixed an issue that caused DbImage not to work when the primary column for the table is a GUID.

2) Added support for compound primary keys (primary key that is more then one column in the table).

3) Added support for Entity Framework (previous release would display images in Entity Framework but fail to update them).

4) The asp:FileUpload control does not work correctly inside of UpdatePanels with partial rendering turned on. By default the templates in Dynamic Data are enclosed in UpdatePanels with partial rendering turned on. This means that uploading of images will fail unless partial rendering is disabled. The new sample adds a helper method call in the Page_Init of the Insert, Edit and ListDetails page templates. This helper call looks to see if any of the displayed columns are DbImage columns and if so turns off partial rendering for the page.

DbImageAPI.ImageHelper.DisablePartialRenderingForUpload(this, DetailsDataSource.GetTable());

Published Tuesday, June 17, 2008 2:07 AM by scothu
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# a-foton » Dynamic Data DbImage SampleUpdated

Tuesday, June 17, 2008 5:47 AM by a-foton » Dynamic Data DbImage SampleUpdated

# a-foton » Dynamic Data DbImage SampleUpdated

Tuesday, June 17, 2008 5:47 AM by a-foton » Dynamic Data DbImage SampleUpdated

# ASP.NET Dynamic Data on CodePlex

Today, ASP.NET Dynamic Data moved from its current home on Code Gallery to its new home on CodePlex . 

Wednesday, June 18, 2008 3:10 AM by David Ebbo's ASP.NET blog

# re: Dynamic Data DbImage SampleUpdated

I downloaded Extracted the files and ran the solution clicked view in browser and got these errors

Error 1 No overload for method 'RegisterControl' takes '2' arguments C:\Users\Owner\Documents\Dynamic Data\DbImageAPI\WebSite\DynamicData\PageTemplates\List.aspx.cs 19 9 C:\...\WebSite\

Error 2 No overload for method 'GetActionPath' takes '1' arguments C:\Users\Owner\Documents\Dynamic Data\DbImageAPI\WebSite\DynamicData\PageTemplates\List.aspx.cs 26 39 C:\...\WebSite\

Saturday, June 28, 2008 4:19 PM by Ricxk

# re: Dynamic Data DbImage SampleUpdated

I commented out the two Pre ceding errors

now I'm grtting these

Error 1 'BooleanField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\Boolean.ascx.cs 25 29 C:\...\WebSite\

Error 2 'ForeignKey_EditField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\ForeignKey_Edit.ascx.cs 48 29 C:\...\WebSite\

Error 3 'MultilineText_EditField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\MultilineText_Edit.ascx.cs 30

Error 4 'Boolean_EditField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\Boolean_Edit.ascx.cs 29

Error 5 'ForeignKeyField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\ForeignKey.ascx.cs 55

Error 6 'Integer_EditField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\Integer_Edit.ascx.cs 31

Error 7 'DateTime_EditField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\DateTime_Edit.ascx.cs 29

Error 8 'Decimal_EditField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\Decimal_Edit.ascx.cs 31

Error 9 'ChildrenField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\Children.ascx.cs 55

Error 10 'DateTimeField.DataControl': no suitable method found to override C:\Users\Owner\Documents\Dynamic Data\DbImage\DbImageAPI\WebSite\DynamicData\FieldTemplates\DateTime.ascx.cs 17

Saturday, June 28, 2008 5:40 PM by Rick

# re: Dynamic Data DbImage SampleUpdated

I downloaded the new Dynamic Data Runtime and Templates 5-23a Refresh

and all seems to be good

Saturday, June 28, 2008 6:35 PM by Rick

# re: Dynamic Data DbImage SampleUpdated

The sample code does not work. I was getting this error:

Error 1 'ChildrenField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Children.ascx.cs 55 29 C:\...\WebSite\

Error 2 'DateTimeField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DateTime.ascx.cs 17

Error 3 'Decimal_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Decimal_Edit.ascx.cs 31

Error 4 'TextField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Text.ascx.cs 17

Error 5 'ForeignKey_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\ForeignKey_Edit.ascx.cs 48

Error 6 'Text_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Text_Edit.ascx.cs 32

Error 7 'MultilineText_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\MultilineText_Edit.ascx.cs 30

Error 8 'DateTime_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DateTime_Edit.ascx.cs 29

Error 9 'ForeignKeyField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\ForeignKey.ascx.cs 55

Error 10 'Boolean_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Boolean_Edit.ascx.cs 29

Error 11 'BooleanField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Boolean.ascx.cs 25

Error 12 'Integer_EditField.DataControl': no suitable method found to override C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\Integer_Edit.ascx.cs 31

As suggested I installed the  new Dynamic Data Runtime and Templates 5-23a Refresh

And now I am getting this error:

Error 2 '$codebesideclassname$' is not a valid value for attribute 'inherits'. C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField_cb.ascx 1

Error 3 '$safeitemrootname$' is not a valid value for attribute 'classname'. C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField.ascx 1

Error 4 '$safeitemrootname$' is not a valid value for attribute 'classname'. C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField_Edit.ascx 1

Error 5 The file '/WebSite/DynamicData/FieldTemplates/$codebehindclassname$_Edit.ascx.cs' does not exist. C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField_Edit_cb.ascx 1

Error 6 '$codebesideclassname$_EditField' is not a valid value for attribute 'inherits'. C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField_Edit_cb.ascx 1

Warning 7 File '$codebesiderootname$.cs' was not found. C:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField_cb.ascx 1 61 C:\...\WebSite\

Error 8 The name 'FieldValueString' does not exist in the current context c:\Documents and Settings\tmahmud\My Documents\Visual Studio 2008\WebSites\DbImageAPI\WebSite\DynamicData\FieldTemplates\DynamicDataField_cb.ascx 3 5 C:\...\WebSite\

Monday, June 30, 2008 11:33 AM by Tareq

# re: Dynamic Data DbImage SampleUpdated

For the sample to work you will need to have the latest Dynamic Data Runtime installed. You can download that from here: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14474.

Also note that this sample has now been moved into the Dynamic Data Futures which you can download from: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14475

Monday, July 21, 2008 12:30 PM by scothu

# re: Dynamic Data DbImage SampleUpdated

Hello, I downloaded the Dynamic Data Futures project and everything worked smoothly.  However, I need to use the dbImage template for a website I'm developing but I cannot get this to work.  The steps I followed are:

1. Copy DbImage.ascx, DbImage_Edit.ascx and FileImage.ascx from the sample website and copied them into my project's FieldTemplate folder.

2. Regenerate the dbml file.

3. Add a Metadata Class for the table that has an Image column and place the following code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Xml.Linq;

using System.Web.DynamicData;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls.WebParts;

using System.ComponentModel.DataAnnotations;

using System.ComponentModel.Design;

using System.ComponentModel;

[MetadataType(typeof(ImagenMetadata))]

public partial class Imagen {}

[TableName("Imagenes")]

public class ImagenMetadata

{  

   //  Show the image

   [UIHint("DbImage")]

   [DisplayName("Fotografía")]

   public object Archivo { get; set; }    

}

Now when I try to edit or insert records into the table "Imagen", the file selector appears but when I select the image and clic on insert/update, an error shows up saying that I need to select an Image.

I'm affraid I am a newby on Dynamic Data so I really do not know what am I doing wrong.

Thank you in advance!

Thursday, March 12, 2009 6:39 PM by Alvaro

# re: Dynamic Data DbImage SampleUpdated

Scott, the DOWNLOAD DBIMAGE link no longer works. It shows this error: There was an error downloading the file. It may have been deleted from the server.

If the DbImage stuff still available somewhere?

Sunday, March 22, 2009 12:07 AM by Dan Crowell

# re: Dynamic Data DbImage SampleUpdated

Brilliant work! I finally got images into my dynamic data site database after trying numerous times!

Friday, March 27, 2009 9:13 AM by Paul

# How to get this to work?

Im with Alvaro

Ive looked at the sample, copied across the FieldTemplates for image i want to use, hooked them up using Meta classes and referenced the Futures DLL.... cant seem to get it to work though...?

Sunday, March 29, 2009 1:42 AM by peter

# how to get this to work?

Im with Alvaro

Ive looked at the sample, copied across the FieldTemplates for image i want to use, hooked them up using Meta classes and referenced the Futures DLL.... cant seem to get it to work though...?

Sunday, March 29, 2009 4:11 AM by peter

# re: Dynamic Data DbImage SampleUpdated

More on the problem it seems -

FileUploadEdit.HasFile always returns false....

any reason for this?

Sunday, March 29, 2009 4:19 AM by peter

# re: Dynamic Data DbImage SampleUpdated

Okay more input.... im having real problems trying to integrate all your code into my existing project. When i move aspects of your code across to my project, i just get build failures on types all the time specially since i have to remove all the dynamic data futures namespace references in each file. When i try compile i just get a "could not find type Edit"

After a whole bunch of waggling around i got the upload to work but the display wont...empty picture boxes.

Sunday, March 29, 2009 6:14 AM by peter

# re: Dynamic Data DbImage SampleUpdated

anyone managed to get this sample to work with ADO .NET entity model designer?

Sunday, March 29, 2009 1:02 PM by peter

# re: Dynamic Data DbImage SampleUpdated

There has not been a post on this since 3.20.09?

After reading the comments it looks like it has possibilities. I have a project that I need this kind of functionality. I've got the System.core. 3.5. I also have installed the sp1 for VS. What are the system requirements for it to work ?

Thanks

Monday, June 29, 2009 8:44 PM by mobocracy

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker