我是asp.net的初学者。我想更新数据库中的数据。但什么也没有发生。我用google,发现问题可以通过ObjectDataSource解决,但不确定。
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [content]" UpdateCommand="UPDATE [content] SET [title] = @title, [article] = @article WHERE [id] = @id">
<UpdateParameters>
<asp:ControlParameter ControlID="txtTitle" Name="title" Type="String" PropertyName="Text" />
<asp:ControlParameter ControlID="txtArticle" Name="article" Type="String" PropertyName="Text" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:DataList ID="DataList2" runat="server" DataKeyField="id" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:TextBox ID="txtTitle" runat="server" Text='<%# Eval("title") %>'></asp:TextBox><br>
<asp:TextBox ID="txtArticle" runat="server" Text='<%# Eval("article") %>'></asp:TextBox><br>
<asp:Button ID="Button1" runat="server" Text="go" />
</ItemTemplate>
</asp:DataList>