我已经创建了一个gridview来更新我的数据库中的新闻表,然后动态更新我的新闻页面但是我在更新标题字段时遇到问题所有其他字段似乎都在更新(时间,作者和内容),但是标题字段似乎没有记录更新。
这是我的news_overiew pasge上网格视图的代码,您可以在其中更新新闻项目:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageCMS.master" %>
<script runat="server">
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="news" Height="252px" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="746px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
<asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
<asp:BoundField DataField="author" HeaderText="author" SortExpression="author" />
<asp:BoundField DataField="content" HeaderText="content" SortExpression="content" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="news" runat="server" ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}"
ConnectionString="<%$ ConnectionStrings:nas connection %>"
DeleteCommand="DELETE FROM [news]
WHERE [title] = @original_title
AND [date] = @original_date
AND [author] = @original_author
AND [content] = @original_content"
InsertCommand="INSERT INTO [news] ([title], [date], [author], [content])
VALUES (@title, @date, @author, @content)"
SelectCommand="SELECT [title], [date], [author], [content] FROM [news]"
UpdateCommand="UPDATE [news] SET [date] = @date, [author] = @author,
[content] = @content
WHERE [title] = @original_title
AND [date] = @original_date
AND [author] = @original_author
AND [content] = @original_content">
<DeleteParameters>
<asp:Parameter Name="original_title" Type="String" />
<asp:Parameter Name="original_date" Type="String" />
<asp:Parameter Name="original_author" Type="String" />
<asp:Parameter Name="original_content" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="title" Type="String" />
<asp:Parameter Name="date" Type="String" />
<asp:Parameter Name="author" Type="String" />
<asp:Parameter Name="content" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="date" Type="String" />
<asp:Parameter Name="author" Type="String" />
<asp:Parameter Name="content" Type="String" />
<asp:Parameter Name="original_title" Type="String" />
<asp:Parameter Name="original_date" Type="String" />
<asp:Parameter Name="original_author" Type="String" />
<asp:Parameter Name="original_content" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
</asp:Content>