This is a migrated thread and some comments may be shown as answers.

Uploading an image

9 Answers 120 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 10 Feb 2009, 11:01 AM
hi

I have gone thru the demo and i still not sure how to go about it

Ok, i have a table(ID, ImagePath). The ID is an autonumber, the ImagePath is nvarchar(200)

The is a folder called ProdImage and this is used to store all product images.

I have a stored Proc for insert and it has a return value of Scope_Identity. The purpose of the return value is to rename the image file using the return value.

I have a RadUpload in a grid and am using In-Form editing for Insert and Update.

Based in the sample demo code, I couldn't not figure out how i should accomplish my task. Please help. Thanks

Protected

 

Sub RadGrid1_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles RadGrid1.ItemInserted

 

InitializeUpdateParameter(

DirectCast(e.Item.FindControl("RadUpload1"), RadUpload))

 

 

End Sub

 

 

Protected Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)

 

InitializeUpdateParameter(

DirectCast(e.Item.FindControl("RadUpload1"), RadUpload))

 

 

End Sub

 

 

Private Sub InitializeUpdateParameter(ByVal currentUpload As RadUpload)

 

 

If currentUpload.UploadedFiles.Count > 0 Then

 

 

Dim data As Byte() = New Byte(currentUpload.UploadedFiles(0).ContentLength) {}

 

currentUpload.UploadedFiles(0).InputStream.Read(data, 0, data.Length)

Session(

"DataVB") = data

 

 

End If

 

 

End Sub

 

9 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Feb 2009, 11:26 AM
Hello L,

Our example implements a different scenario - it uploads the image directly into the database. In your case you need to save the file first and then call the stored procedure passing it the file name of the uploaded file.
You can check the following help articles for additional information:
http://www.telerik.com/help/aspnet-ajax/upload_raduploadtargetfolder.html
http://www.telerik.com/help/aspnet-ajax/upload_raduploadmanipulatingfiles.html

All the best,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
L
Top achievements
Rank 1
answered on 10 Feb 2009, 11:53 AM
hi

Ok, but i think i need to save the data first to get the Primary Key value and renaming the image with the key value before saving the image to a folder.

Also, i have read the links you have pointed me to but still i am quite lost about getting my task accomplish.

Thanks
0
L
Top achievements
Rank 1
answered on 11 Feb 2009, 04:31 AM
hi

I'll think of a work around. By the way, how do I display the "Add New Record" permanently when there are no data on the grid?
0
L
Top achievements
Rank 1
answered on 11 Feb 2009, 05:07 AM
hi

Ok, i have the Add New Record thing solved. Also where can i download the demo or example for this link?

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultvb.aspx?product=upload

I need to know the DB structure and it sources. Thanks

Thanks
0
Veselin Vasilev
Telerik team
answered on 11 Feb 2009, 08:26 AM
Hi Lui,

You can find this demo on your computer under:

<RadControls installation folder> \ Live Demos \ Controls \ Examples \ Integration \ RadUploadInAjaxifiedGrid

I hope this helps.

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
L
Top achievements
Rank 1
answered on 11 Feb 2009, 08:53 AM
hi

First of all thanks.

I have the complete DB and source, but what must i change so that i can test the actual insert and update? It seems that is based on session. Thanks
0
L
Top achievements
Rank 1
answered on 12 Feb 2009, 02:06 AM
hi

Based on the demo that is locally installed onto my pc. Everything works fine except that everthings are in sessions. I have seen the images table but right now i wnat to insert and edit and delete in and from the image table not using sessions. So, which part of the cod must i change to allow these functions? Please help. Thanks
0
Accepted
Veselin Vasilev
Telerik team
answered on 12 Feb 2009, 09:31 AM
Hello Lui,

You need to replace the SessionDataSource with your datasource (SqlDataSource, AccessDataSource, etc.).

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
L
Top achievements
Rank 1
answered on 12 Feb 2009, 01:33 PM
hi

Ok, It works fine now. Sorry, this is the first time i encounter SessionDataSource thing.
Tags
Upload (Obsolete)
Asked by
L
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
L
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or