C# 通过SQL表,使用ASP.NET显示存储在文本框中的数据

C# 通过SQL表,使用ASP.NET显示存储在文本框中的数据,c#,asp.net,sql-server,asp.net-mvc,asp.net-mvc-4,C#,Asp.net,Sql Server,Asp.net Mvc,Asp.net Mvc 4,这是我的控制器: public ActionResult Actualizarperfil(registro m) { masterEntities db = new masterEntities(); ViewBag.Lista = db.registro.Where(x => x.usuario == m.usuario).ToList(); return View(); } 因此,我将其发送到带有值

这是我的控制器:

    public ActionResult Actualizarperfil(registro m)
    {
        masterEntities db = new masterEntities();
     
        ViewBag.Lista = db.registro.Where(x => x.usuario == m.usuario).ToList();
        return View();
    }
因此,我将其发送到带有值的文本框中调用:

    <div class="form-group">
       <label for="Nombre" class="col-sm-3 control-label">Nombre</label>
        <div class="col-sm-9">
            <input type="text"
                 name="nombre"
                 placeholder="Nombre"
               class="form-control" required autofocus value="@Html.DropDownList("MiLista", new SelectList(ViewBag.Lista, "Nombre", "Nombre"))">
    </div>
</div>

名义
但我的错误是,它没有在文本框中显示任何内容:

我会错在哪里?或者有其他选择吗?

而不是这个:

<input type="text"
           name="nombre"
           placeholder="Nombre"
           class="form-control" required autofocus value="@Html.DropDownList("MiLista", new SelectList(ViewBag.Lista, "Nombre", "Nombre"))">
据我所见,目前您正在指定一本教科书,但希望它是一个下拉列表。因此,您要么使用
标记,要么使用下面这样的替代方法


注意:如果我想通过选择表中存储的几个字段发送到某个文本框进行打印,也可以使用
DropDownListFor
@Html.DropDownList("MiLista", new SelectList(ViewBag.Lista, "Nombre", "Nombre", "Nombre"), new { @class="form-control"})