473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

FileUpload Control in FormView using ObjectDataSource

Hello,
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
below:
<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
fileupload).

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 =
upLoadFile.FileName;

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
0 2744

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris | last post by:
I want to display a formview based on an objectdatasource. One of the things on the formview will be a link to a pdf. When I go into the edit template I would like a fileupload to display, which...
2
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
4
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that...
0
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have...
6
by: Chris | last post by:
I want do my insert to a database using a formview bound to an objectdatasource. I also want to upload a file. I'm quite new to and this is just test code but Is there any way I can pass the file...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
0
by: =?Utf-8?B?RQ==?= | last post by:
The issue is that I have two formviews in a multiview. The second formview's objectdatasource references controls in the first formview. If the query to populate the first formview results in...
1
by: bogdan | last post by:
Hi, I have a FormView where one of the items is a file name. All items come from a single data source. I'd like to have the file name also displayed in a FileUpload control on the same page. ...
5
by: =?Utf-8?B?VEQgaXMgUFNQ?= | last post by:
I have a FileUpload control within a FormView (although I tried it outside the FormView and got the same result) in the InsertTemplate. When the <Insertbutton is clicked and the Insert Command is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.