Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 编辑模式下的嵌套RadGrid具有未更改的值_C#_Asp.net_Telerik_Radgrid - Fatal编程技术网

C# 编辑模式下的嵌套RadGrid具有未更改的值

C# 编辑模式下的嵌套RadGrid具有未更改的值,c#,asp.net,telerik,radgrid,C#,Asp.net,Telerik,Radgrid,我最近发现了如何在任何时候引用嵌套的RadGrid控件,就像在中一样 但是,我的主网格和嵌套网格处于编辑模式,在回发期间嵌套网格中的任何新值都不存在。如果我在任何列中编辑一个值,然后单击我的按钮触发回发,当我访问嵌套的RadGrid时,其值将保持不变(新值与旧值相同) aspx(不包括结束标记、客户端JavaScript方法定义和其他随机设置): 是否有其他方法获取嵌套的RadGrid或其项,以便显示其编辑的值?此问题的原因是第0个索引处的项不是整个网格,而是网格的当前行。我没有看到任何新值的原

我最近发现了如何在任何时候引用嵌套的RadGrid控件,就像在中一样

但是,我的主网格和嵌套网格处于编辑模式,在回发期间嵌套网格中的任何新值都不存在。如果我在任何列中编辑一个值,然后单击我的按钮触发回发,当我访问嵌套的RadGrid时,其值将保持不变(新值与旧值相同)

aspx(不包括结束标记、客户端JavaScript方法定义和其他随机设置):


是否有其他方法获取嵌套的RadGrid或其项,以便显示其编辑的值?

此问题的原因是第0个索引处的项不是整个网格,而是网格的当前行。我没有看到任何新值的原因是因为我只检查行集合中的第一行(
Items[0]

解决方案是循环通过主RadGrid中的每一行,并针对每一行(
Items[i]
)获取嵌套RadGrid及其行:

for (int i = 0; i < RadGrid1.EditItems.Count; i++)
{
    var items = ((RadGrid1.MasterTableView.Items[i].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) ?? "";

            // valNew contains new values if they were changed by the user!
        }
    }
}
for(int i=0;i
您能提供您的aspx页面代码吗?已发布网格的aspx标记。我删除了额外的信息,比如
ClientSettings
EditItemStyle
。我得到了答案@JayeshGoyani。谢谢你看这个。嗨@DanM7,你能编辑一下你的答案吗?因为我错投了否决票。现在它锁定了,我无法恢复它。如果你修改答案,我可以投票。谢谢
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!
    }
}
for (int i = 0; i < RadGrid1.EditItems.Count; i++)
{
    var items = ((RadGrid1.MasterTableView.Items[i].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) ?? "";

            // valNew contains new values if they were changed by the user!
        }
    }
}