DEV-aspxgridview EditForm的使用、验证

相关的连接一:https://search.devexpress.com/?q=aspxgridview%20get%20value%20from%20EditItem&m=SupportCenter

该链接汇总了所有如何从EditForm中获得值的问题的解决方法,但太过于广泛。

相关连接二:https://www.devexpress.com/Support/Center/Example/Details/E1174

通过该程序你可以在后台获得EditForm中aspxcheckbox的值,主要程序为:

private string GetCategoriesFromList() {
        string categories = string.Empty;
//主要是通过改代码获得EditForm中其他控件的属性,第一个参数为控件的列,第二个为所取控件ID, CheckBoxList list
= (CheckBoxList)Grid.FindEditRowCellTemplateControl((GridViewDataColumn)Grid.Columns[2], "List"); // workaround if(Grid.IsCallback) LoadListControlPostDataOnCallback(list); foreach(ListItem item in list.Items)
    {
    //获取
CheckBoxList控件的多个选中值
    if(item.Selected) categories += item.Value + CategorySeparator; 
    }

if(categories.EndsWith(CategorySeparator))
categories
= categories.Substring(0, categories.Length - CategorySeparator.Length);
return categories;
}

相关连接三:https://www.devexpress.com/Support/Center/Example/Details/E1264

该程序讲述了如何对EditForm中的行进行验证,并且错误提示。其中ASPxTextBox在行初始化的时候便提示不能为空的验证。

增加相关行验证的连接:https://www.devexpress.com/Support/Center/Example/Details/E139

以及其演示:http://codecentral.devexpress.com/E139/

该连接演示了行值初始化(不是较为好的方法),对行进行验证,验证失败后显示错误。

添加连接:http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/EditFormTemplate.aspx

该链接演示了EditFormTemplate与EditForm的连用,tab1为自动生成的,tab2为后期添加

相关连接四:https://www.devexpress.com/Support/Center/Example/Details/E25

运行后:http://codecentral.devexpress.com/E25/

改程序是一个很好的EditForm样例,它可以包含许多的其他控件。值得一看。

如何初始化EditForm中各个控件的值

 相关连接:https://www.devexpress.com/Support/Center/Question/Details/Q319768

即使用ASPxGridView.CellEditorInitialize 时间,在事件中可使用the e.Editor.Value (e.Column.FieldName == FieldNameHere) 的值获得相应的值

具体方法如下:在ASPxGridView.CellEditorInitialize

  if (e.Column.FieldName == "DAYS")
      {
        ASPxTextBox txt = e.Editor as ASPxTextBox;
        if (!Grid.IsNewRowEditing)
        { 
          object val = Grid.GetRowValuesByKeyValue(e.KeyValue, e.Column.FieldName);
          if (val == null) txt.Value = null;
        }
      }

 方法二:

使用<asp:FormView ID="FormView1" runat="server" DataKeyNames="ProductID" OnDataBinding="FormView1_DataBinding">

相关例子:https://www.devexpress.com/Support/Center/Example/Details/E529/

使用FormView的加载为其他的参数进行赋值。

当修改和新建不同时

修改中有不需要修改 ,但需要显示的控件时 应使用

grid_CellEditorInitialize和 ASPxGridView.IsNewRowEditing

这两事件

相关连接:https://www.devexpress.com/Support/Center/Question/Details/Q281906

连接中有一些连接可以看一下,参考一下

 

 

 

 

 

posted @ 2015-07-01 16:34  丝竹之约  阅读(2243)  评论(0编辑  收藏  举报