我最近弄清楚如何在my answer here的任何時候引用一個嵌套的RadGrid控件。編輯模式下的嵌套RadGrid值沒有變化
但是,我的主網格和嵌套網格處於編輯模式,嵌套網格中的任何新值在回發期間都不存在。如果我在任何列中編輯一個值,然後點擊我的按鈕來觸發回發,當我訪問嵌套的RadGrid時,其值保持不變(新值與舊值相同)。
ASPX(不包括結束標籤和客戶端的JavaScript方法定義和其他隨機設置):
<telerik:RadGrid ID="RadGrid1" runat="server" HeaderStyle-Width="675px" Width="675px" Height="359px" PageSize="10" GridLines="None" AccessKey="0" Skin="Office2007" ImagesPath="~/Skins/Office2007/Grid/Images" AllowFilteringByColumn="false" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false"
OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated" OnEditCommand="RadGrid1_EditCommand" OnCancelCommand="RadGrid1_CancelCommand" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" >
<MasterTableView Name="Parent" HierarchyDefaultExpanded="false" HierarchyLoadMode="ServerBind" DataKeyNames="ID" EditMode="InPlace" >
<NestedViewTemplate>
<asp:Panel ID="RadGrid2" runat="server" >
<telerik:RadGrid ID="rgDetailItems" runat="server" Width="1675px" AutoGenerateColumns="false" AllowPaging="false" ShowFooter="true"
OnEditCommand="rgDetailItems_EditCommand" OnCancelCommand="rgDetailItems_CancelCommand" OnUpdateCommand="rgDetailItems_UpdateCommand"
OnNeedDataSource="rgDetailItems_NeedDataSource" OnItemDataBound="rgDetailItems_ItemDataBound" >
<MasterTableView EditMode="InPlace">
<Columns>
<telerik:GridBoundColumn HeaderText="Amount" DataField="DtlTransAmount" UniqueName="DtlTransAmount" SortExpression="DtlTransAmount"
HeaderStyle-Width="20px" ItemStyle-Width="20px" FilterControlWidth="20px" DataFormatString="{0:$0.00}"/>
CS:
var items = ((RadGrid1.MasterTableView.Items[0].ChildItem as GridNestedViewItem)
.FindControl("RadGrid2") as RadGrid).EditItems;
foreach (GridEditableItem editItem in items)
{
Hashtable newValues = new Hashtable();
editItem.OwnerTableView.ExtractValuesFromItem(newValues, editItem);
foreach (DictionaryEntry de in newValues)
{
string valOld = (editItem.SavedOldValues[de.Key] as string) ?? "";
string valNew = (newValues[de.Key] as string) ?? "";
// valOld always equals valNew!
}
}
是否有不同的方式來獲得嵌套radgrid控件或它的項目,所以它的編輯值存在?
能否請您提供您的aspx頁面的代碼? – 2014-09-04 16:20:33
發佈爲網格的aspx標記。我刪除了'ClientSettings'和'EditItemStyle'等額外信息。 – DanM7 2014-09-04 16:33:43
我得到了答案@JayeshGoyani。感謝您看看這個。 – DanM7 2014-09-05 21:03:11