嵌套的RadGrid错误的结果

时间:2015-04-28 08:46:29

标签: c# asp.net gridview telerik radgrid

我使用的是Asp.net C#Telerik NestedGrid。当我按第一行展开时我得到了正确的结果但是当我按第二行时我得到第一行的结果由于某种原因我无法获得新值。 我做错了什么以及如何解决它?
我是否需要制作类似的东西:
 protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)

在aspx中

<telerik:RadGrid ID="RadGrid1" runat="server" GroupPanelPosition="Top"  Skin="Outlook" Visible="False" AllowPaging="True" >
     <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="DocHandle" PageSize="20"   >
       <Columns>
                <telerik:GridBoundColumn DataField="DocDescr"  HeaderText="DocDescr" ReadOnly="True" SortExpression="DocDescr"/>
                <telerik:GridBoundColumn DataField="DocHandle" HeaderText="DocHandle" ReadOnly="True" SortExpression="DocHandle" />
                <telerik:GridBoundColumn DataField="CreationDate" HeaderText="CreationDate" ReadOnly="True" SortExpression="CreationDate" DataFormatString="{0:yyyy-MM-dd}" />
       </Columns>
         <NestedViewSettings DataSourceID="SqlDataSource1">
         <ParentTableRelation>
        <telerik:GridRelationFields DetailKeyField="DocHandle" MasterKeyField="DocHandle" />
      </ParentTableRelation>
       </NestedViewSettings>
        <NestedViewTemplate>
            <asp:Panel ID="NestedViewPanel" runat="server" CssClass="viewWrap">
        <div class="contactWrap">
          <fieldset style="padding: 10px;">
            <legend style="padding: 5px;"><b>Detail info for Document: <%#Eval("DocHandle") %></b>
            </legend>
            <table>
              <tr>
                <td>
                 Document Description:
                </td>
                <td>
                  <asp:Label ID="titleLabel" Text='<%#Bind("DocDescr") %>' runat="server"></asp:Label>
                </td>
                  </tr>
                <tr>
                <td>
                 Creation Date:
                </td>
                <td>
                  <asp:Label ID="ownerLabel" Text='<%#Bind("CreationDate", "{0:yyyy-MM-dd}") %>' runat="server" ></asp:Label>
                </td>
                  </tr>
                <tr>
                <td>
                 Created By:
                </td>
                <td>
                  <asp:Label ID="createdbyLabel" Text='<%#Bind("CreatedBy") %>' runat="server"></asp:Label>
                </td>
                  </tr>
                </table>
              </fieldset>
            </div>
                </asp:Panel>
                   </NestedViewTemplate>
       </MasterTableView>
    </telerik:RadGrid>

1 个答案:

答案 0 :(得分:0)

删除以下

>     <NestedViewSettings DataSourceID="SqlDataSource1">
>              <ParentTableRelation>
>             <telerik:GridRelationFields DetailKeyField="DocHandle" MasterKeyField="DocHandle" />
>           </ParentTableRelation>
</NestedViewSettings>

来自您的代码,它应该没问题。