| 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; } |
| } |
| 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); |
| } |
| <telerik:RadPageView runat="server" ID="CMPageView" Width="460px"> | |
| <div class="viewWraptabs tabposition arial"> | |
| <p class="red">Date: <%=DateTime.Now.ToShortDateString() %></p> | |
| <uc2:ssncontrol id="ssn" runat="server" controlposition="16,65" tbwidth="155px"/> | |
| <asp:requiredvalidator id="rvdob" runat="server" controltovalidate=="RadDatePicker1" errormessage="dob is required"/> | |
| <span class="positionT arial">Date of Birth*: </span> | |
| <telerik:raddatepicker id="RadDatePicker1" runat="server" skin="Black" cssclass="positionTD" width="130px" calendar-rangemindate="1/1/1940 12:00:00 AM" mindate="1/1/1940 12:00:00 AM" dateinput-mindate="1/1/1940 12:00:00 AM" /> | |
| <span class="positionS arial">Have you ever had an accident:<span class="space80"></span> <asp:checkbox id="cbacc" runat="server"/></span> | |
| <span class="positionSD arial">Have you ever been charged<br /> with a violation?<span class="space50"></span><asp:checkbox id="cbv" runat="server"/></span> | |
| <textarea id="taacc" cols="30" rows="5" class="positionF" runat="server" validateemptytext="true" validationgroup="mmm"></textarea> | |
| <textarea id="taviol" cols="30" rows="5" class="positionFD" runat="server"></textarea> | |
| <div style="background: url(Img/bg.gif) no-repeat; width: 600px; height: 362px; padding-top: 24px; | |
| text-align: center;position:absolute;left:150px;top:290px"> | |
| <asp:Button Text="Add Member Info" OnClick="AddMemberInfo_Click" runat="server" ID="bmember" | |
| Style="width: 116px;" causesvalidation="true" usesubmitbehavior="true"></asp:Button> | |
| <asp:Button Text="Cancel" runat="server" ID="bcancel" causesvalidation="false" | |
| Style="width: 116px;"></asp:Button> | |
</div> ...etc...
|
|
Hi,
I'm having a problem when I delete the last item in a detail table, which causes the parent row to be deleted as well.
I get client errors saying "Parent table relations set, but no corresponding data-key name found" and "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
The master table and the detail table are both bound at the same time during the grids NeedDataSource event. I have tried setting the HierarchyLoadMode to different values, but it didn't help.
The delete command item is on the child table. The delete happens successfully, the DataSource is set to null, the NeedDataSource event occurs, and table is given new data for both the master table and the detail table.
The error only happens when the row is the very LAST row in the grid and all the child items are deleted, causing the parent row to disappear. If it’s the first row or one of the middle rows, no error occurs. If it is the only row in the grid you receive the error "Parent table relations set, but no corresponding data-key name found". If there's more than 1 row, you get the "Index was out of range" error.
Anyone ever encounter anything like this? Any ideas for workarounds?
Thanks
-Adam