C# 带有实体框架6的Asp.net webforms更新页面

C# 带有实体框架6的Asp.net webforms更新页面,c#,asp.net,webforms,entity-framework-6,C#,Asp.net,Webforms,Entity Framework 6,我正在使用asp.NETWebForms,我是实体框架的初学者。我需要知道如何创建一个更新页面并将数据从页面发送到一个方法(绑定),而不必逐个字段绑定并保存更改 假设我有这个班: public class Fiche { [Key] public int Id { get; set; } public string mrmme { get; set; } public string nometprenom { get; set; } public str

我正在使用asp.NETWebForms,我是实体框架的初学者。我需要知道如何创建一个更新页面并将数据从页面发送到一个方法(绑定),而不必逐个字段绑定并保存更改

假设我有这个班:

public class Fiche
{
    [Key]
    public int Id { get; set; }
    public string mrmme  { get; set; }
    public string nometprenom { get; set; }
    public string adresse { get; set; }
    public string ville { get; set; }
    public string cp { get; set; }
    public string tele { get; set; }
    public string portable { get; set; }
    public string datenaissance { get; set; }
    public string email { get; set; }
    public string situation { get; set; }
    public string profession { get; set; }

    #region // Santé & Prévoyance
    public string typesp { get; set; }
    public string nombresassures { get; set; }
    public string regime { get; set; }
    public string nbrenfants { get; set; }
    public string mutuelleactuelle { get; set; }
    public string tarifcontrat { get; set; }
    public string niveaugaranties { get; set; }
    public string mutuelle { get; set; }
    #endregion 

    public string Createdbynom { 
        get {
            return Data.Db.Users.Find(Createdby).nom;
        }
    }

    public string Affectedtonom
    {
        get
        {
            return Data.Db.Users.Find(Affectedto).nom;
        }
    }

    public ICollection<Contrat> Contrats { get; set; }
    public ICollection<Commentaire> Commentaires { get; set; }

    public string Createdby { get; set; }
    [ForeignKey("Createdby")]
    public ApplicationUser createuser { get; set; }

    public string Affectedto { get; set; }

    [ForeignKey("Affectedto")]
    public ApplicationUser affetcteduser { get; set; }
}
公共类Fiche
{
[关键]
公共int Id{get;set;}
公共字符串mrmme{get;set;}
公共字符串nometprenom{get;set;}
公共字符串地址{get;set;}
公共字符串{get;set;}
公共字符串cp{get;set;}
公共字符串tele{get;set;}
公共字符串可移植{get;set;}
公共字符串datenaissance{get;set;}
公共字符串电子邮件{get;set;}
公共字符串情况{get;set;}
公共字符串职业{get;set;}
#地区//Santé&Prévoyance
公共字符串类型sp{get;set;}
公共字符串nombressures{get;set;}
公共字符串机制{get;set;}
公共字符串nbrenfants{get;set;}
公共字符串mutuelleactuelle{get;set;}
公共字符串tarifcontrat{get;set;}
公共字符串niveaugaranties{get;set;}
公共字符串mutuelle{get;set;}
#端区
公共字符串Createdbynom{
得到{
返回Data.Db.Users.Find(Createdby).nom;
}
}
公共字符串影响的符号
{
得到
{
返回Data.Db.Users.Find(Affectedto).nom;
}
}
公共ICollection contracts{get;set;}
公共ICollection注释{get;set;}
通过{get;set;}创建的公共字符串
[外键(“Createdby”)]
公共应用程序用户createuser{get;set;}
影响{get;set;}的公共字符串
[外键(“受影响”)]
公共应用程序用户影响用户{get;set;}
}
如果我想创建一个表单来更新这个模型,我有很多字段。我需要为每个字段创建文本框,当我单击“提交”按钮时,我需要从每个文本框中获取每个值,并绑定到模型并调用
存储技术

这是webforms中更新数据库数据的唯一方法吗


有没有办法将数据从我的表单绑定到我的更新方法

签出:但这是用于绑定gridview中的数据,如果表单包含文本框和提交方法之间的绑定,则这不仅适用于gridview-您还可以将带有多个文本框、复选框等的
FormView
DetailView
绑定到模型类