Where can i find some examples of using a RADUpload in a grid that doesnt use GridBinaryImageColumn
Im storing the URL of the image, not the binary contents of the image itself
The method im using doesnt work as UploadedFiles are always zero, heres how Im trying to make it work, in my grid
and then in my codebehind
Im storing the URL of the image, not the binary contents of the image itself
The method im using doesnt work as UploadedFiles are always zero, heres how Im trying to make it work, in my grid
<telerik:GridTemplateColumn HeaderText="Image File" UniqueName="ImageUpload"> |
<ItemTemplate> |
<asp:Label ID="LabelImage" runat="server" Text='<%# Eval("FileName") %>'></asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadUpload ID="RadUploadImage" runat="server" |
InitialFileInputsCount="1" MaxFileInputsCount="1" |
ControlObjectsVisibility="None" MaxFileSize="100000" |
AllowedFileExtensions=".jpg,.gif,.jpeg" TargetFolder="~/Uploads"/> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
and then in my codebehind
protected void RadGridPanelImages_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
var editableItem = ((GridEditableItem)e.Item); |
string thumbURL = string.Empty; |
string ImageURL = string.Empty; |
string url = TheCompanyBL.Helpers.GetSiteURL(); |
string ImageUploadURL = url + "/Uploads/"; |
RadComboBox rcb = (RadComboBox)e.Item.FindControl("RadComboBoxPanelID"); |
if (rcb != null) |
{ |
ip.PanelID = int.Parse(rcb.SelectedValue); |
} |
else |
{ |
ip.PanelID = -1; |
} |
int id = -1; |
RadUpload ru = (RadUpload)e.Item.FindControl("RadUploadImage"); |
if (null != ru) |
{ |
string target = Server.MapPath(ru.TargetFolder); |
string sFileType = ru.UploadedFiles[0].GetExtension(); --- this generates an error even though I HAVE selected a file |
ip.FileName = ru.UploadedFiles[0].FileName; |
imagemanager.ResizeAndSave(ru.UploadedFiles[0], ImageUploadURL, target, "PanelImages", true, out thumbURL); |
imagemanager.ResizeAndSave(ru.UploadedFiles[0], ImageUploadURL, target, "PanelImages", false, out ImageURL); |
ip.ImageURL = ImageURL; |
ip.ThumbnailURL = thumbURL; |
} |
if (!String.IsNullOrEmpty(thumbURL) && !String.IsNullOrEmpty(ImageURL)) |
{ |
string err = panelmanager.Add(ip, out id); |
} |
} |