从gridview

时间:2016-01-08 08:42:52

标签: asp.net devexpress

我希望显示器不是idchef,但是nomchef表有一个表projet和table chef之间的关系,当我使用tolist它显示idchef 如何从table projet中显示来自table chef而不是idchef的nom 这是代码控制器:

 public ActionResult ListeProjets()
        {

            GestionprojetEntities db = new GestionprojetEntities();

            var model = db.Projet.ToList();
            return View("ListeProjets", model);
        }

这是代码视图:

@using GestionProjet.Models;
@model List<GestionProjet.Models.Projet>
@{
    ViewBag.Title = "ListeProjets";
}





            @Html.DevExpress().GridView(settings =>
       {
           settings.Name = "GridView";
           settings.KeyFieldName = "Id";
           settings.SettingsBehavior.AllowSelectByRowClick = true;
           settings.SettingsBehavior.AllowFocusedRow = true;

           settings.SettingsBehavior.AllowSelectSingleRowOnly = true;

           settings.ClientSideEvents.RowClick = "function(s, e){rowSelected(s, e)}";

           settings.Columns.Add("Nom");
           settings.Columns.Add("Description");
           settings.Columns.Add("Datedebut");

           settings.Columns.Add("Complexite");
           settings.Columns.Add("Taille");
           settings.Columns.Add("IdChef");
           settings.Columns.Add("IdClient");





           settings.CommandColumn.Visible = true;
           settings.Width = Unit.Percentage(100);
           settings.Settings.ShowGroupPanel = true;
           settings.Settings.ShowTitlePanel = true;
           settings.Settings.ShowFooter = true;

           settings.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(160);

           settings.Styles.GroupRow.Font.Bold = true;
           settings.Styles.Row.BackColor = System.Drawing.ColorTranslator.FromHtml("#F7EEEE");
           settings.SettingsText.Title = "Liste Des Projets";
           settings.SettingsText.GroupPanel = "Liste Des Projets";

       }).Bind(Model).GetHtml()

有人可以帮我解决这个问题,谢谢你

1 个答案:

答案 0 :(得分:0)

这样怎么样:

        BoundField col= new BoundField();
        col.DataField = "IdChef";
        col.Headertext = "nomChef";                
        settings.Columns.Add(col);