In my grid I have 3 columns, a combo, textbox and RADUpload
in the UpdateCommand event I create an instance of the combo, textbox and RADUpload
If the user hasnt uploaded any files, I want to keep the original uploadURL values, How can I get to them from the UpdateCommand Event ?
the datasource bound to the grid is simply a list of a custom class Ive created
So in the UpdateCommande event I simply want to get access to the contents of the original PhotoURL & ThumbnailURL
These arent displayed in the grid, but they are part of the datasource.
Ive tried to cast the dataItem to my custom class but its always null
TheCompanyBL.CastMemberObj member = (TheCompanyBL.CastMemberObj)e.Item.DataItem;
can anyone help me out ?
in the UpdateCommand event I create an instance of the combo, textbox and RADUpload
If the user hasnt uploaded any files, I want to keep the original uploadURL values, How can I get to them from the UpdateCommand Event ?
the datasource bound to the grid is simply a list of a custom class Ive created
| public class CastMemberObj |
| { |
| public int ID { get; set; } |
| public string CastMemberName { get; set; } |
| public string CastMemberInformation { get; set; } |
| public string PhotoURL { get; set; } |
| public string ThumbnailURL { get; set; } |
| public string Type { get; set; } |
| } |
These arent displayed in the grid, but they are part of the datasource.
| protected void RadGridCast_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| var editableItem = ((GridEditableItem)e.Item); |
| var productId = (int)editableItem.GetDataKeyValue("ID"); |
| TheCompanyBL.CastMemberObj castmember = new TheCompanyBL.CastMemberObj(); |
| string thumbURL = string.Empty; |
| string ImageURL = string.Empty; |
| string url = TheCompanyBL.Helpers.GetSiteURL(); |
| string ImageUploadURL = url + "/Uploads/"; |
| RadTextBox tb = (RadTextBox)e.Item.FindControl("txbCastMember"); |
| if (tb != null) |
| { |
| castmember.CastMemberName = tb.Text; |
| } |
| else |
| { |
| castmember.CastMemberName = ""; |
| } |
| RadComboBox rcb = (RadComboBox)e.Item.FindControl("RadComboBoxType"); |
| if (rcb != null) |
| { |
| castmember.Type = rcb.SelectedValue; |
| } |
| else |
| { |
| castmember.Type = ""; |
| } |
| TheCompanyBL.CastMemberObj member = (TheCompanyBL.CastMemberObj)e.Item.DataItem; |
| Image img = (Image)e.Item.FindControl("ImageThumbNail"); |
| if (null != img) |
| { |
| } |
| RadUpload ru = (RadUpload)e.Item.FindControl("RadUploadImage"); |
| if (null != ru) |
| { |
| string target = Server.MapPath(ru.TargetFolder); |
| if (ru.UploadedFiles.Count > 0) |
| { |
| string sFileType = ru.UploadedFiles[0].GetExtension(); |
| foreach (UploadedFile f in ru.UploadedFiles) |
| { |
| imagemanager.ResizeAndSave(ru.UploadedFiles[0], ImageUploadURL, target, "CastMembers", true, out thumbURL); |
| imagemanager.ResizeAndSave(ru.UploadedFiles[0], ImageUploadURL, target, "CastMembers", false, out ImageURL); |
| castmember.ThumbnailURL = thumbURL; |
| castmember.PhotoURL = ImageURL; |
| } |
| } |
| } |
| //retrive entity form the Db |
| //update entity's state |
| //editableItem.UpdateValues(castmember); |
| string err = castmembermanager.Update(castmember); |
| } |
Ive tried to cast the dataItem to my custom class but its always null
TheCompanyBL.CastMemberObj member = (TheCompanyBL.CastMemberObj)e.Item.DataItem;
can anyone help me out ?