Radupload how save in binary

Thread is closed for posting
10 posts, 1 answers
  1. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 29 Jun 2011 Link to this post


    how to store the attachment file in stored to database

    Thanks,
    Mohamed.
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 29 Jun 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 29 Jun 2011 Link to this post

    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.
  5. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 29 Jun 2011 Link to this post

    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.
  6. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 29 Jun 2011 Link to this post


    this field is binary
    ormm.image =


    Thanks,
    Mohamed.
  7. Answer
    Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 30 Jun 2011 Link to this post

    Try this:

    ormm.image = new Binary(attachmentBytes);

    I hope that helps.
  8. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 01 Jul 2011 Link to this post

    Hello Kevin,

    Thanks For Ur reply .
    It's Worked ...

    one more doubt,
    how to bind in radgrid through needdatasource

    Thanks,
    Mohamed.
  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Jul 2011 Link to this post

    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.
  10. mohamed
    mohamed avatar
    311 posts
    Member since:
    Mar 2011

    Posted 01 Jul 2011 Link to this post

    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.
  11. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 05 Jul 2011 Link to this post

    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.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017