FormView+LinqDataSource的更新代码
我的代码如下,没有cs代码,点击delete和insert都是有反应的,但那是点击update,就直接返回readonly模式了,没有执行任何的数据库操作<asp:LinqDataSource ContextTypeName="mm.Core.Model.MmDataContext" TableName="Articles"
ID="LinqDataSource1" EnableUpdate="true" EnableInsert="true" EnableDelete="true"
runat="server" Where="Id=@Id">
<WhereParameters>
<asp:QueryStringParameter Type="Int32" DefaultValue="1" Name="Id" QueryStringField="Id" />
</WhereParameters>
</asp:LinqDataSource>
<asp:FormView ID="FormView1" DataSourceID="LinqDataSource1" AllowPaging="true" runat="server"
DataKeyNames="Id" onpageindexchanging="FormView1_PageIndexChanging">
<HeaderStyle ForeColor="white" BackColor="Blue" />
<ItemTemplate>
<table>
<tr>
<td align="right">
<b>标题</b>
</td>
<td>
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>' />
</td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="EditButton" Text="Edit" CommandName="Edit" runat="server" />
<asp:LinkButton ID="NewButton" Text="New" CommandName="New" runat="server" />
<asp:LinkButton ID="DeleteButton" Text="Delete" CommandName="Delete" runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table>
<tr>
<td align="right">
<b>标题</b>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Title") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="UpdateButton" Text="Update" CommandName="Update" runat="server" />
<asp:LinkButton ID="CancelUpdateButton" Text="Cancel" CommandName="Cancel" runat="server" />
</td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td align="right">
<b>标题</b>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Title") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="InsertButton" Text="Insert" CommandName="Insert" runat="server" />
<asp:LinkButton ID="CancelInsertButton" Text="Cancel" CommandName="Cancel" runat="server" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView> --------------------编程问答-------------------- d --------------------编程问答-------------------- 翻遍了互联网没有一篇完整介绍formview+linqdatasource的
很无奈。 --------------------编程问答-------------------- d
补充:.NET技术 , ASP.NET