嵌套的 RadGrid 错误结果
Nested RadGrid Wrong Results
我正在使用 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>
删除以下内容
> <NestedViewSettings DataSourceID="SqlDataSource1">
> <ParentTableRelation>
> <telerik:GridRelationFields DetailKeyField="DocHandle" MasterKeyField="DocHandle" />
> </ParentTableRelation>
</NestedViewSettings>
根据你的代码应该没问题。
我正在使用 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>
删除以下内容
> <NestedViewSettings DataSourceID="SqlDataSource1">
> <ParentTableRelation>
> <telerik:GridRelationFields DetailKeyField="DocHandle" MasterKeyField="DocHandle" />
> </ParentTableRelation>
</NestedViewSettings>
根据你的代码应该没问题。