样本
<asp:GridView ID="data_basic_addresses" runat="server" AllowPaging="False" BorderWidth="0" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="AddressId" HorizontalAlign="Center"
DataSourceID="LinqAddressDS" PageSize="20" CssClass="GridViewClass">
<Columns>
<asp:BoundField DataField="AddressId" HeaderText="AddressId" SortExpression="AddressId" ReadOnly="True"/>
<asp:BoundField DataField="Address" HeaderText="Street" SortExpression="Address" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
<asp:CommandField HeaderText="Options" ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="LinqAddressDS" runat="server" OnContextCreating="LinqDS_ContextCreating" Where="AcctNo == @AcctNo"
ContextTypeName="MyProject.Models.DB_DataDataContext" EnableDelete="True" EnableInsert="True"
EnableUpdate="True" TableName="Tbl_Addresses" OrderBy="AddressId">
<WhereParameters>
<asp:QueryStringParameter DefaultValue="1" Name="AcctNo" QueryStringField="AcctNo" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
我在 page_load 方法中设置 WhereParamater 值
每次更改数据后按下更新链接时,我都会收到一条错误消息,指出“发生严重错误。调用目标引发了异常”。或“无法访问已处置的对象”
当网格视图重新加载时,数据会更新。我所做的一切似乎都没有改变。有人对为什么有任何想法吗?
提前致谢!