我有一个asp.net 网页,其中包含一个启用了编辑、选择和删除功能的gridview,以及一个用于插入新记录的detailview。每个控件都放置在一个 asp.net ajax 扩展控件更新面板中。并且这两个控件绑定到同一个数据源,即 LinqDataSource。
插入新记录后,gridview 中不会显示任何内容,直到用户刷新页面。我错过了什么?任何人都可以帮忙吗?
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<fieldset>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="TermLinqDataSource" AllowPaging="True" AllowSorting="True"
DataKeyNames="TermID">
<Columns>
<asp:CommandField
ShowSelectButton="True" />
<asp:BoundField DataField="RowIndex" HeaderText="RowIndex"
InsertVisible="False" SortExpression="RowIndex" Visible="False" />
<asp:BoundField DataField="TermID" HeaderText="Term" ReadOnly="True"
SortExpression="TermID" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date"
SortExpression="StartDate" DataFormatString="{0:d}" />
<asp:BoundField DataField="EndDate" HeaderText="End Date"
SortExpression="EndDate" DataFormatString="{0:d}" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<h4>Add New Term:</h4>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DetailsView ID="addNewTerm" runat="server"
AutoGenerateRows="False" DataKeyNames="TermID"
DataSourceID="TermLinqDataSource" DefaultMode="Insert">
<FieldHeaderStyle Font-Bold="true" />
<Fields>
<asp:BoundField DataField="TermID" HeaderText="Term:" SortExpression="TermID"
ReadOnly="True" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date:"
SortExpression="StartDate" />
<asp:BoundField DataField="EndDate" HeaderText="End Date:"
SortExpression="EndDate" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:LinqDataSource ID="TermLinqDataSource" runat="server"
ContextTypeName="CETMSClient.RegistraDCsDataContext" EnableDelete="True"
EnableInsert="True" EnableUpdate="True" TableName="Terms"
OrderBy="RowIndex desc" >
</asp:LinqDataSource>