我不知道如何将此代码更改为 MVC,有人可以帮我做或解释我该怎么做,
这是关于修改编辑和删除数据库的组件
我需要理解它并在 3 天内完成。很多谢谢:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="1_DetailsView.aspx.cs" Inherits="GridView_Edit._1_DetailsView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="299px"
AutoGenerateRows="False" DataKeyNames="idL" DataSourceID="SqlDataSource1"
AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<Fields>
<asp:BoundField DataField="idL" HeaderText="idL" InsertVisible="False"
ReadOnly="True" SortExpression="idL" />
<asp:BoundField DataField="krstne" HeaderText="krstne"
SortExpression="krstne" />
<asp:BoundField DataField="spec" HeaderText="spec" SortExpression="spec" />
<asp:BoundField DataField="datNar" HeaderText="datNar"
SortExpression="datNar" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowInsertButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Fields>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
</asp:DetailsView>
<!-- Datum sa neUpdejtuje ;) -->
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PoliklinikaConnectionString3 %>"
SelectCommand="SELECT * FROM [Lekari]"
UpdateCommand="Update [Lekari] SET krstne=@krstne, spec=@spec WHERE idL=@idL"
InsertCommand="Insert [Lekari] Values(@krstne, @spec, @datNar)"
DeleteCommand="Delete [Lekari] Where idL=@idL"
></asp:SqlDataSource>
</div>
</form>
</body>
</html>