如何在MVC Devexpress Gridview编辑中找到控件?

时间:2014-02-21 02:32:08

标签: asp.net-mvc asp.net-mvc-4 devexpress aspxgridview

我在editform中的文本框

Html.DevExpress().TextBox(
    edtSettings =>
    {
        edtSettings.Name = "ID";
        edtSettings.ShowModelErrors = true;
        edtSettings.Width = Unit.Percentage(100);
        edtSettings.Height = Unit.Pixel(30);
    }).Bind(DataBinder.Eval(c.DataItem, "ID")).Render();

editform创建活动

settings.HtmlEditFormCreated = (sender, e) =>
    {
        var s = sender as MVCxGridView;
        if (!s.IsNewRowEditing)
        {
            ASPxTextBox txtID = ((ASPxTextBox)s.FindEditFormTemplateControl("ID"));
            if (txtID != null)
            {
                txtID.ReadOnly = true;
            }
        }
    };
我调试时,

txtID为null。如何找到它?

1 个答案:

答案 0 :(得分:2)

为什么呢?只需在其“设置”对象中直接自定义“ID”TextBox:

Html.DevExpress().TextBox(edtSettings => {
    edtSettings.Name = "ID";
    //ALL SETTINGS ARE RIGHT HERE...

}).Bind(DataBinder.Eval(c.DataItem, "ID")).Render();