小编Mir*_*war的帖子

使用实体框架asp.net mvc登录进程

我想在我的项目中登录密码验证.当用户点击登录按钮时,编译器转到此方法

public ActionResult VerifyPassword(User user)
{
    var givenPassword =user.Password;
    var givenUserName=user.UserName;
//now i need compare password 
    var myUser=db.User.Find(somevalue)//find user from database,
    But how can i do this????Because somevalue needs to be a Primary Key

}
Run Code Online (Sandbox Code Playgroud)

如果我做错了什么.请指出我正确的方向我在网上搜索了很多.但没有找到使用实体框架完成此任务的教程.

c# asp.net-mvc entity-framework

6
推荐指数
1
解决办法
2万
查看次数

将动态创建的控件数据保存在数据库中asp.net mvc

我正在使用具有项目列表的 viewbag 创建控件

 public ActionResult Create()
        {
            var savedAdditionalFields = afs.getAllStudentFieldss(1);
            ViewBag.AdditionalFieldList = savedAdditionalFields;
            return View();
        }
Run Code Online (Sandbox Code Playgroud)

在我正在使用的视图中

创造

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>StudentAdditionalDetail</legend>

    @foreach (MyClass item in ViewBag.AdditionalFieldList)
        { 

        <div>

            @Html.DisplayFor(itemlist=>item.Name)

            @Html.EditorFor(model=>model.AdditionalInfo)

        </div>
        }
Run Code Online (Sandbox Code Playgroud)

控件和标签已创建。现在我正在使用将项目保存在数据库中

[HttpPost]

 public ActionResult Create(StudentAdditionalDetail additionalFields)

        {   
            ads.AddAdditionalDetails(additionalFields);//calls the insert method

            return RedirectToAction("Index");

        }
Run Code Online (Sandbox Code Playgroud)

但只有第一个文本框的数据保存在数据库中。我想我需要迭代我的 [HttpPost] 创建方法。但不确定我应该将迭代整个创建视图和所有项目的代码放在哪里

模型.附加信息

将被保存到数据库中

c# asp.net asp.net-mvc asp.net-mvc-4

5
推荐指数
1
解决办法
1833
查看次数

设置列extjs的默认值

在这里,我在网格中有一些列,我想在'receivedquantity'字段中给出默认值,默认情况下,收到的数量字段将等于"Quantity"字段.如果用户编辑该字段,那么数据将来自数据库我在这里使用mvc模式......

this.columns=
    [
    {
    header:'name',
    dataIndex:'name'},
    {
    header:'Quantity',
    dataIndex:'quantity',
    },
    {
    header:'Received Quantity',
        dataIndex:'receivedquantity',
        selectOnFocus: true,
        filterable:true,
        renderer:function(val, meta, record){
        var receivedquantity = record.data.receivedquantity;
var quantity=record.data.quantity;
        if(receivedquantity==0)//by default receivedquantity=0
        {
        //set (receivequantity=quantity) in the grid's received quantity cell 
        }},
     editor: {allowBlank:false
     }
            }
                ];
Run Code Online (Sandbox Code Playgroud)

extjs extjs-mvc

1
推荐指数
1
解决办法
4881
查看次数