GridView的编辑功能不起作用 点击编辑,更新后,数据并没有改变,删除功能可以实现
<asp:AccessDataSourceID="Products"runat="server"DataFile="~/Products.accdb"SelectComm...
<asp:AccessDataSource ID="Products" runat="server" DataFile="~/Products.accdb" SelectCommand="SELECT * FROM Products"
UpdateCommand="Update Products SET 书名=@书名, 类别号=@类别号, 类别=@类别, 价格=@价格 WHERE (书号=@书号)"
DeleteCommand="DELETE From Products WHERE 书号=@书号" />
<asp:GridView ID="grid1" runat="server" Width="100%" DataSourceID="Products" HeaderStyle-BackColor="#FF99CC" BorderColor="black" AutoGenerateColumns="false"
AllowPaging="true" PageSize="15" PagerSettings-Position="TopAndBottom" PagerSettings-Mode="NextPreviousFirstLast"
PagerSettings-FirstPageText="第一页" PagerSettings-PreviousPageText="前一页" PagerSettings-NextPageText="下一页" PagerSettings-LastPageText="最后一页"
PagerStyle-HorizontalAlign="Center" PagerStyle-BackColor="#E0E0E0" OnDataBound="GridViewDataBound" OnPageIndexChanged="GridViewIndexChanged"
AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" DataKeyNames="书号">
<Columns>
<asp:BoundField HeaderText="书号" DataField="书号" />
<asp:BoundField HeaderText="书名" DataField="书名" />
<asp:BoundField HeaderText="类别号" DataField="类别号" />
<asp:BoundField HeaderText="类别" DataField="类别" />
<asp:BoundField HeaderText="价格" DataField="价格" />
</Columns>
</asp:GridView>
终于知道哪有问题了,书号没有SET 书号=@书号的话就要在下面的<asp:BoundField HeaderText="书号" DataField="书号" />中加上 ReadOnly="true" 展开
UpdateCommand="Update Products SET 书名=@书名, 类别号=@类别号, 类别=@类别, 价格=@价格 WHERE (书号=@书号)"
DeleteCommand="DELETE From Products WHERE 书号=@书号" />
<asp:GridView ID="grid1" runat="server" Width="100%" DataSourceID="Products" HeaderStyle-BackColor="#FF99CC" BorderColor="black" AutoGenerateColumns="false"
AllowPaging="true" PageSize="15" PagerSettings-Position="TopAndBottom" PagerSettings-Mode="NextPreviousFirstLast"
PagerSettings-FirstPageText="第一页" PagerSettings-PreviousPageText="前一页" PagerSettings-NextPageText="下一页" PagerSettings-LastPageText="最后一页"
PagerStyle-HorizontalAlign="Center" PagerStyle-BackColor="#E0E0E0" OnDataBound="GridViewDataBound" OnPageIndexChanged="GridViewIndexChanged"
AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" DataKeyNames="书号">
<Columns>
<asp:BoundField HeaderText="书号" DataField="书号" />
<asp:BoundField HeaderText="书名" DataField="书名" />
<asp:BoundField HeaderText="类别号" DataField="类别号" />
<asp:BoundField HeaderText="类别" DataField="类别" />
<asp:BoundField HeaderText="价格" DataField="价格" />
</Columns>
</asp:GridView>
终于知道哪有问题了,书号没有SET 书号=@书号的话就要在下面的<asp:BoundField HeaderText="书号" DataField="书号" />中加上 ReadOnly="true" 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询