Working with ObjectDataSource selected object from codebehind

G

Guest

Hi there,

I quite new to posting in this forum.

I have a problem which I truly hope someone can help me out.

I have a master/detail page - with a gridview displaying company names, and
a DetailsView displaying the selected company from dridview.
I'm able to use the DetailsView to insert and update members of the site
(companies), but I have this problem with a FileUpload, which is bound to a
templatefield in the DetailsView control.

I have created an eventhandler for the DetailsView_ItemInserting in which
I'm validating whether a file was posted.
If the FileUpload contains a file, the filename should be set to a string
vallue, the file should be uploaded to a folder on the site and finally, the
object's property Logo from the DetailsView, should be set to the string
value.

I can upload the file and insert the record, but it doesn't come with the
logo in the database.

My question is now. How do I actually update the DetailsView/ or the
ObjectDataSource so that the logo property will be altedered if there's a
file and the changes are written to the datastore.

My app is build with dataclasses and ObjectDataSources in the presentation
layer and I therefore need a way to update the currently selected object (if
updating) or alter the new object before it's values are written via the
DetailsView back to the ObjectDataSource control.

Thanks in advance!
 
G

Guest

Hi again,

I'm not sure if I made myself completely clear in the first post.

As mentioned, everything with the insert and update works fine, except that
the filename doesn't come with the object back to the ObjectDataSource.

What I would like to do is to determine whether a file was actually posted
through the FileUpload control in the templatefield and if so, attach the
filename to the currently build object in the objectDatasource so that the
filename will be written to the database with the rest of the objects values.
I'm trying to do this from the code behind file.

I'm trying to determine whether a file was posted in the DetailsView
ItemInserting event, and if so, I will propably need to do something else,
maybee in the ObjectDataSource events somewhere.

Anybody have a clue on this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top