locked
dropdownlist in webgrid using mvc4 RRS feed

  • Question

  • Dear friends

    i have got the func<dynmic,object> error when binding the dropdown value in Webgrid

    my coding s

    Model:

    public string UserLastName { get; set; }
            public string UserEmail { get; set; }
            public string UserRole { get; set; }

    public class UserAccount
        {
            public IEnumerable<Users> _User { get; set; }
            public IEnumerable<SelectListItem> UserRoles { get; set; }

    }

    Controller:

    public ActionResult Users()
            {

    var Data = _objUserRespository.GetUser();
                var Model = new UserAccount();
                {
                    Model._User = Data;                
                    Model.UserRoles = new[]{
                        new SelectListItem{Text = "Admin",Value="Admin"},
                        new SelectListItem{Text = "Trader",Value="Trader"}
                    };
                }
                return View(Model);

    View:

    @model  dataanalysys.Models.UserAccount

    var grid = new webgrid(model._user)

    @grid.gethtml(

    columns:grid.columns(

    grid.column("userlastanem"),

    grid.column("useremail"),

     grid.Column("UserRole", "User Role", format: @<text><span class="display-mode">
                                             <label id="lblusrrole">
                                                 @item.UserRole
                                             </label>
                                         </span>

                  

    @Html.DropDownList("UserRole",Model.UserRoles,new { id = "UserRole", @class = "edit-mode" })

                </text>)

    how to solve this error , can anyone help me.




    Sumathi


    • Moved by Max Meng Monday, June 17, 2013 2:27 AM
    • Edited by sumathisumi Monday, June 17, 2013 6:51 AM
    Friday, June 14, 2013 2:02 PM

Answers

  • I'd suggest you start by reposting this in a visual studio forum, rather than an office forum.

    al


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP

    Friday, June 14, 2013 3:14 PM