views:

32

answers:

1

I am developing a small, internal-use only web application. Given its simple nature and intended audience, I decided that it might be a good opportunity to use a ASP.NET Dynamic Data project to get things up-and-running quickly. So far so good, except for one issue that has me reconsidering the whole plan:

I need to be able to upload files through the website. There is an entity in the model that represents an uploaded file. This entity has properties for the file's contents, the file name, and the file's content type. When uploading a file, all of these values are obtained from a single FileUpload control.

Since a FieldTemplate has a one-to-one association with an entity property, I decided that I needed to create a custom EntityTemplate for the File entity. At this point, I have created an "edit" template for the entity that has a FileUpload control. What I have not been able to figure out is, when the user clicks the 'Update' link, how do I get the data from the FileUpload control back into the entity and (ultimately) into the database.

Any advice or guidance is much appreciated.

+1  A: 

Hi Daniel, you can add other values to the dictionary in the ExtractValues method of the FiedlTemplate, what you have to be aware of is that if those values also appear as rows or column in the page template then they will overwrite the values you added. I usually scaffold them as false and then only referance them in the custom field template.

Note you can access their initial values from the Row property in the OnDataBinding event, you can cast the property as the actual type or use an interface added via buddy classes.

Wizzard