LINQ to SQL之面向对象的添加、查询、更新和删除

介绍
以Northwind为示例数据库,DLINQ(LINQ to SQL)之完全面向对象的添加操作、查询操作、更新操作和删除操作

示例
Sample.ASPx

<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile=
      "
Sample.ASPx.cs"
    Inherits
="LINQ_DLINQ_Sample" Title="面向对象的添加、查询、更新和删除" 
%>

<ASP:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</ASP:Content>
<ASP:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    
<p>
        分类名称:
<ASP:TextBox ID="txtCategoryName" runat="server"></ASP:TextBox>
        
&nbsp;&nbsp; 分类描述:<ASP:TextBox ID="txtDescription" runat="server"></ASP:TextBox>
        
&nbsp;&nbsp;
        
<ASP:Button ID="btnAdd" runat="server" Text="添加" OnClick="btnAdd_Click" />
    
</p>
    
<ASP:GridView ID="gvCategory" runat="server" DataKeyNames="CategoryID"
              OnSelectedIndexChanged
="gvCategory_SelectedIndexChanged"        OnRowDeleting="gvCategory_RowDeleting" OnRowCancelingEdit="gvCategory_RowCancelingEdit"
        OnRowEditing
="gvCategory_RowEditing" OnRowUpdating="gvCategory_RowUpdating">
        
<Columns>
            
<ASP:CommandField ShowSelectButton="True" ShowEditButton="True"
                   ShowDeleteButton
="True">
            
</ASP:CommandField>
        
</Columns>
    
</ASP:GridView>
    
<br />
    
<ASP:DetailsView ID="dvProduct" runat="server" DataKeyNames="ProductID">
    
</ASP:DetailsView>
</ASP:Content>

it知识库LINQ to SQL之面向对象的添加、查询、更新和删除,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。