简体   繁体   English

DevExpress GridView for MVC - 如何为模板单元设置默认值

[英]DevExpress GridView for MVC - How to set default value for template cell

In a Developer Express GridView in cshtml file I have a column declared as follows:在 cshtml 文件中的 Developer Express GridView 中,我有一列声明如下:

settings.Columns.Add(column =>
{
    column.FieldName = "DOCENTE_ID";
    column.Caption = "Docente";
    column.SetDataItemTemplateContent(container =>
    {
        var doc = DataBinder.Eval(container.DataItem, "DesDocente") as string;
        ViewContext.Writer.Write("{0}", doc);
    });

    column.SetEditItemTemplateContent(container =>
    {
        Html.RenderAction("TeachersPartial", new
        {
            bindingName = "DOCENTE_ID",
            esse3_id = DataBinder.Eval(container.DataItem, "DOCENTE_ID")
       });
    });
});

I have to set DOCENTE_ID default value to 39735.我必须将 DOCENTE_ID 默认值设置为 39735。

This default value must come into play when the user does not select a value in the combo.当用户没有 select 组合值时,此默认值必须发挥作用。

How can I do?我能怎么做? Thanks in advance,提前致谢,

Simone西蒙妮

You can initialize a default value in the following manner:您可以通过以下方式初始化默认值:

column.SetEditItemTemplateContent(container =>
{
    object esse3_id_value_or_default = DataBinder.Eval(container.DataItem, "DOCENTE_ID") ?? 39735;
    Html.RenderAction("TeachersPartial", new
    {
        bindingName = "DOCENTE_ID",
        esse3_id = esse3_id_value_or_default
   });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从不在GridView中的组合框在devexpressfocusedrowhandle中设置单元格值 - Set cell value in devexpress focusedrowhandle from combo box that is not in the gridview 在devexpress gridview中未设置RipositoryItemCombobox值 - RipositoryItemCombobox value not set in devexpress gridview 在Winforms Devexpress中,如何在GridView中的单元格中获取TextEdit值? - How to get TextEdit value to Cell in GridView in Winforms Devexpress? 如何清除Gridview Winforms Devexpress中有界列的单元格值? - How to clear a cell value of bounded column in Gridview Winforms Devexpress? Devexpress Gridview如何获取十进制类型单元格中的行值? - Devexpress Gridview how get row value in decimal type cell? 如何在DevExpress Gridview中获取单元格索引? - How to get cell index in DevExpress Gridview? DevExpress GridView:如何添加LookUpEdit单元 - DevExpress GridView: how to add a LookUpEdit cell 如何为“未绑定列”单元格设置值? (SetRowCellValue)Grinview Winforms Devexpress - How to set a value to Unbound Column cell ? (SetRowCellValue) Grinview Winforms Devexpress 将data- *属性添加到DevExpress MVC gridview单元 - Adding data-* attributes to a DevExpress MVC gridview cell 如何在ControlGrid 1级GridView C#中获取单元格值或行值-DevExpress - How to get a cell value or row value in ControlGrid Level 1 GridView C# - DevExpress
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM