9 Answers, 1 is accepted
0
Cori
Top achievements
Rank 2
answered on 29 Jun 2011, 01:05 PM
Hello mohamed,
Here's how you would read a uploaded file's bytes:
// get uploaded file
UploadedFile attachment = RadUpload1.UploadedFiles[0];
// create byte array
byte
[] attachmentBytes =
new
byte
[attachment.InputStream.Length];
// read attachment into byte array
attachment.InputStream.Read(attachmentBytes, 0, attachmentBytes.Length);
You then just pass the byte array into your update statement.
I hope that helps.
0
mohamed
Top achievements
Rank 1
answered on 29 Jun 2011, 01:17 PM
hello cori.
// this my table sample name
rmm ormm = new rmm();
// get uploaded file
UploadedFile attachment = fileBrowser.UploadedFiles[0];
// create byte array
byte[] attachmentBytes = new byte[attachment.InputStream.Length];
// read attachment into byte array
attachment.InputStream.Read(attachmentBytes, 0, attachmentBytes.Length);
ormm.image = how to pass that byte value
ormm.gfhg = oKBArticle.KBRowId;
try { DbClient.Insert<rmm>(ormm); }
catch (Exception ex1) { }
Thanks,
Mohamed.
// this my table sample name
rmm ormm = new rmm();
// get uploaded file
UploadedFile attachment = fileBrowser.UploadedFiles[0];
// create byte array
byte[] attachmentBytes = new byte[attachment.InputStream.Length];
// read attachment into byte array
attachment.InputStream.Read(attachmentBytes, 0, attachmentBytes.Length);
ormm.image = how to pass that byte value
ormm.gfhg = oKBArticle.KBRowId;
try { DbClient.Insert<rmm>(ormm); }
catch (Exception ex1) { }
Thanks,
Mohamed.
0
Cori
Top achievements
Rank 2
answered on 29 Jun 2011, 01:19 PM
You would pass it as is.
Isn't your image property a byte array? If not, it should, as that's the only way to store it.
Isn't your image property a byte array? If not, it should, as that's the only way to store it.
0
mohamed
Top achievements
Rank 1
answered on 29 Jun 2011, 01:48 PM
this field is binary
ormm.image =
Thanks,
Mohamed.
0
Accepted
Kevin
Top achievements
Rank 2
answered on 30 Jun 2011, 01:47 PM
Try this:
ormm.image = new Binary(attachmentBytes);
I hope that helps.
ormm.image = new Binary(attachmentBytes);
I hope that helps.
0
mohamed
Top achievements
Rank 1
answered on 01 Jul 2011, 07:12 AM
Hello Kevin,
Thanks For Ur reply .
It's Worked ...
one more doubt,
how to bind in radgrid through needdatasource
Thanks,
Mohamed.
Thanks For Ur reply .
It's Worked ...
one more doubt,
how to bind in radgrid through needdatasource
Thanks,
Mohamed.
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2011, 07:52 AM
Hello Mohamed,
Check the following help documentation and demo which explains how to bind RadGrid through NeedDataSource event.
Advanced Data-binding (using NeedDataSource event).
Grid / Advanced Data Binding.
Thanks,
Shinu.
Check the following help documentation and demo which explains how to bind RadGrid through NeedDataSource event.
Advanced Data-binding (using NeedDataSource event).
Grid / Advanced Data Binding.
Thanks,
Shinu.
0
mohamed
Top achievements
Rank 1
answered on 01 Jul 2011, 07:55 AM
Hello shinu,
i binding attachment field ,
i click file will open .
like that like
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/gridattachmentcolumn/defaultcs.aspx
Thanks ,
Mohamed.
i binding attachment field ,
i click file will open .
like that like
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/gridattachmentcolumn/defaultcs.aspx
Thanks ,
Mohamed.
0
Kevin
Top achievements
Rank 2
answered on 05 Jul 2011, 01:35 PM
Hello mohamed,
If you notice in the demo, you need to have a DataSourceID set for the attachment column to render, if you're using declarative databinding.
In your case, you want to use NeedDataSource to bind the RadGrid, so you shouldn't use the GridAttachmentColumn, but instead use a GridButtonColumn with a command name set to something like 'DownloadFile' and then transmit the file in the same manner as the demo shows in the ItemCommand event.
I hope that helps.
If you notice in the demo, you need to have a DataSourceID set for the attachment column to render, if you're using declarative databinding.
In your case, you want to use NeedDataSource to bind the RadGrid, so you shouldn't use the GridAttachmentColumn, but instead use a GridButtonColumn with a command name set to something like 'DownloadFile' and then transmit the file in the same manner as the demo shows in the ItemCommand event.
I hope that helps.