栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

JQuery对ASP.NET MVC数据进行操作

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JQuery对ASP.NET MVC数据进行操作

以前学习ASP.NET MVC时,学习与应用,操作过数据显示,添加,编辑,更新和删除等功能。

很多方法是相通的,看自己是怎样来进行方便,快捷,高效率。

今天Insus.NET写的练习,是直接对绑定在Table的数据进行更新,删除。

在项目中,创建一个实体,也就是说,对数据库时行通信,对数据进行操作:

public IEnumerable GetAllToolLocations()
        {
            sp.ConnectionString = DB.ConnectionString;
            sp.Parameters = null;
            sp.ProcedureName = "usp_ToolLocation_GetAll";
            DataTable dt = sp.ExecuteDataSet().Tables[0];
            return dt.ToList();
        }

        public void Update(ToolLocation tl)
        {
            List param = new List() {
                                    new Parameter("@ToolLocation_nbr", SqlDbType.SmallInt, 2, tl.ToolLocation_nbr),
                                    new Parameter("@LocationName",SqlDbType.NVarChar,-1,tl.LocationName),
                                    new Parameter("@Description",SqlDbType.NVarChar,-1,tl.Description),
                                    new Parameter("@IsActive",SqlDbType.Bit,1,tl.IsActive)
            };
            sp.ConnectionString = DB.ConnectionString;
            sp.Parameters = param;
            sp.ProcedureName = "usp_ToolLocation_Update";
            sp.Execute();
        }

        public void Delete(ToolLocation tl)
        {
            List param = new List() {
                                    new Parameter("@ToolLocation_nbr", SqlDbType.SmallInt, 2, tl.ToolLocation_nbr)
            };
            sp.ConnectionString = DB.ConnectionString;
            sp.Parameters = param;
            sp.ProcedureName = "usp_ToolLocation_Delete";
            sp.Execute();
        }

 

创建视图,并绑定数据:

@using Insus.NET.Models;
@model IEnumerable




    
    Edit
    
    
   


    
        
            
                
                
                
                
                
            
            @foreach (var tl in Model)
            {
                
                    
                    
                    
                    
                    
                
            }
        
ToolLocation_nbrLocationNameDescriptionIsActive
@tl.ToolLocation_nbr@Html.TextBox("LocationName", tl.LocationName)@Html.TextBox("Description", tl.Description) @Html.CheckBox("IsActive", tl.IsActive)                                              
    


对数据进行更新的功能,下面的实现,是对Table内的数据删除。


@using Insus.NET.Models;
@model IEnumerable






Delete







@foreach (var tl in Model)
{

}
ToolLocation_nbr LocationName Description IsActive
@tl.ToolLocation_nbr @tl.LocationName @tl.Description @Html.CheckBox("IsActive", tl.IsActive, new { disabled = "disabled" })


 

 


 


 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/231627.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号