我有一个带有选择链接的网格视图。据说,当我单击选择链接时,应该出现 DataKeyNames 的特定详细信息。
但是,就我而言,每当我单击“选择”时,只会出现一条记录,并且它不会更改并与所选 DataKeyNames 的数据匹配。我已经阅读了网上的许多示例,并且我做的完全一样,但是它不能正常工作。。
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:WholesaleConnectionString %>"
SelectCommand="SELECT [poNum], [retailerID] FROM [PO]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="poNum" DataSourceID="SqlDataSource1" >
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="poNum" HeaderText="poNum" InsertVisible="False"
ReadOnly="True" SortExpression="poNum" />
<asp:BoundField DataField="retailerID" HeaderText="retailerID"
SortExpression="retailerID" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:WholesaleConnectionString %>"
SelectCommand="SELECT [poNum], [quantity], [unitPrice], [totalAmt], [grandTotal] FROM [PO]">
<SelectParameters>
<asp:ControlParameter Name="poNum" ControlID="GridView1" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource2"
Height="50px" Width="125px">
</asp:DetailsView>