By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

FileUpload Control in FormView using ObjectDataSource

P: n/a
I have a Formview in insert mode with a fileUpload control on it. I'm
trying to get the contents of the uploaded file passed to my ObjectDataSource
to be persisted to my database. The Method called by the Insert method takes
a parametare called DocBlob of type byte[] for the file contents. When I
generate an object datasource using this method, it generates the parameter
<asp:Parameter Name="DocBlob" Type="Object" />

Now in the item inserting event of my ObjectDatasource, I need to set the
value of this paramater (because i can't Bind to the contents of a

I get the bytes of the uploaded files by using upLoadFile.FileBytes wihich
is of type byte[]. My Method takes a Byte[] also. so far so good ... I got
a byte[] and my Insermethod needs a byte[].

Now I need to pass the fiename and contents from my aspx to my insert method
via the Objectdatasource.
for the filename i use this code :
ObjectDataSourceFormView.InsertParameters["FileName"].DefaultValue =

but for the DocBlob byte[] I cant do this. The DefauktValue needs to be a
string, I cant set it to a byte[];

Can anyone offer some advice? I tried overloading my insrt method and gav a
version that took a string, converted it to a byte[] the called my original
method, but i couldnd firgure out how to properly encode an uploaded file as
a string. I tried UTF8Encoding and UTF32Encoding, but neither worked.

I;m thinkning i should just give up on the Object datasource and call my
method directly.

Sep 2 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.