ASPX到MVC微软的Visual Studio 2012

问题描述:

我不知道如何改变这种代码MVC, 有人可以帮我做 它或解释我如何能做到这一点,ASPX到MVC微软的Visual Studio 2012

这是关于修改编辑和 删除数据库的一个组成部分

我需要理解它,并在3天内做到最大。许多THX:

<%@ 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 [email protected], [email protected] WHERE [email protected]" 
     InsertCommand="Insert [Lekari] Values(@krstne, @spec, @datNar)" 
     DeleteCommand="Delete [Lekari] Where [email protected]" 
     ></asp:SqlDataSource> 

    </div> 
    </form> 
</body> 
</html> 
+0

如果这只是与数据库表直接相关的项目的编辑/删除功能,那么您可以在ASP.NET MVC中使用大部分即用功能来实现此功能。从Nerd Dinner教程开始,了解ASP.NET MVC的工作原理。如果您期待从WebForms到MVC的逐行转换,则会导致比解决更多的问题。 – David

MVC是一种完全不同的方式来构建Web应用程序。最大的区别是消除了网页控制,转而使用更轻量级的HTML帮助程序。由于您提出这个问题,我假设您可能需要更好地了解MVC,以便了解如何获取现有Web窗体应用程序的业务需求,并将其应用于MVC应用程序。

我知道你的时间有限,但我建议通过this tutorial。试图在没有至少这种理解水平的情况下急于进入解决方案只会让你自己和你的客户失去帮助。