我创建了一个 Web 应用程序并包含一个 GridView,它将从表中检索记录testtable
。
代码如下:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="product_no" HeaderText="product_no"
InsertVisible="False" ReadOnly="True" SortExpression="product_no" />
<asp:BoundField DataField="product_name" HeaderText="product_name"
SortExpression="product_name" />
<asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
<asp:BoundField DataField="expire_date" HeaderText="expire_date"
SortExpression="expire_date" />
<asp:BoundField DataField="expire_time" HeaderText="expire_time"
SortExpression="expire_time" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testbaseConnectionString %>"
DeleteCommand="DELETE FROM testtable WHERE (product_no = @product_no)"
InsertCommand="INSERT INTO testtable(product_name, price, expire_date, expire_time) VALUES (@product_name, @price, @expire_date, @expire_time)"
SelectCommand="SELECT testtable.* FROM testtable"
UpdateCommand="UPDATE testtable SET product_name = @product_name, price = @price, expire_date = @expire_date, expire_time = @expire_time WHERE (product_no = @product_no)">
<DeleteParameters>
<asp:Parameter Name="product_no" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="product_name" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="product_name" />
<asp:Parameter Name="price" />
<asp:Parameter Name="expire_date" />
<asp:Parameter Name="expire_time" />
<asp:Parameter Name="product_no" />
</UpdateParameters>
</asp:SqlDataSource>
但是,当我单击Edit
GridView 的特定记录的链接并进行一些更改时,我单击了该Update
链接,但未反映更改,并且似乎没有更新到表中。(Edit
链接看起来和下图中的一模一样)
我会错过什么?