1
Answer

How to upload multiple images using a Telerik RadUpload

I have the following code in my asp.net form.
protected void RadButton1_Click(object sender, EventArgs e)
        {
            try
            {
                Guid eventid = Guid.Parse(Request.QueryString["id"]);

                foreach (UploadedFile file in RadUpload1.UploadedFiles)
                {
                    Guid pId = Guid.NewGuid();
                    byte[] bytes = new byte[file.ContentLength];
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    csPicture objpics = new csPicture();
                    objpics.PicId = pId;
                    objpics.PicDescription = file.GetNameWithoutExtension();
                    objpics.Picture = bytes;
                    objpics.EventId = eventid;
                    objpics.Add_Image();
                }
            }
            catch (Exception ex)
            {
                lblerror.Text = ex.Message;
            }
        }
when I trace trough the program it doesn't even go inside the foreach...does anyone know any alternative to this or any other way I can use to upload multiple images at the same time.

Regards!

Answers (1)

0
Photo of Carlos Sanchez
NA 264 0 20y
Thank you jshepler. I prefer the first method, cuz is esier and cuz I dont know if the second method is possible in C#. thank you again, I appreciate your help. Regards.
0
Photo of jshepler
NA 63 0 20y
2 ways to do this: 1. Combine the two (or more) columns in your select statement: SELECT IDEmploee, Name + ' ' + LastName + ' ' + SecondLastName AS 'Employee'. You would then have 2 columns: IDEmployee and Employee. 2. Tell the datagrid not to automatically generate the columns - do them manually: Employee <%# DataBinder.Eval(Container.Dataitem, "Name") %> <%# DataBinder.Eval(Container.Dataitem, "LastName") %> <%# DataBinder.Eval(Container.Dataitem, "SecondLastName") %> The first method is the preferred way unless you need to have the columns seperate for something else. Having the database doing the work is much more efficient, not to mention easier to code.