• devexpress中应用于girdviw中HtmlDataCellPrepared事件与CellEditorInitialize事件的区别


    HtmlDataCellPrepared 事件为页面展示的时候对页面做的初始化(将id变为name)

    ​CellEditorInitialize 事件为页面在编辑时(新增、修改)时做的初始化,如将值填入下拉列表中。

    ///

    /// 初始化GRID的部门名称

    ///

    protected void grid_UserList_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)

    {

    DataTable dt = new DataTable();

    dt = customerservicebll.DeptList(PEOID).Tables[0];//获取登录企业ID下的所有部门列表

    if (e.DataColumn.FieldName == "DEPID")

    {

    DataRow[] Row = (DataRow[])dt.Select(" DEPID = " + e.CellValue.ToString() + " ");//根据每行部门ID筛选dt中对应的部门名称并放入数组

    foreach (DataRow row in Row)

    {

    e.Cell.Text = row["DEPNAME"].ToString();//在数组中找到DEPNAME标记的值赋值给单元格

    }

    }

    }

    ///

    /// 编辑时各种初始化

    ///

    protected void grid_UserList_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)

    {

    if (!grid_UserList.IsNewRowEditing)

    {

    if (e.Column.FieldName == "USERPWD")

    {

    ASPxTextBox textbox = new ASPxTextBox();

    textbox = e.Editor as ASPxTextBox;

    textbox.Enabled = false;

    textbox.Password = true;

    //e.Editor.Enabled = false;

    }

    }

    else

    {

    if (e.Column.FieldName == "USERPWD")

    {

    e.Editor.Value = "888888";

    }

    }

    if (e.Column.FieldName == "DEPID")

    {

    ASPxComboBox combox = new ASPxComboBox();

    combox = e.Editor as ASPxComboBox;

    DataTable dt = new DataTable();

    dt = customerservicebll.DeptList(PEOID).Tables[0];

    if (dt.Rows.Count > 0)

    {

    foreach (DataRow dr in dt.Rows)

    {

    combox.Items.Add(dr["DEPNAME"].ToString(), dr["DEPID"].ToString());

    }

    }

    }

    if (e.Column.FieldName == "TPOST_ID")

    {

    ASPxComboBox combox = new ASPxComboBox();

    combox = e.Editor as ASPxComboBox;

    DataTable dt = new DataTable();

    dt = customerservicebll.PostList(PEOID).Tables[0];

    if (dt.Rows.Count > 0)

    {

    foreach (DataRow dr in dt.Rows)

    {

    combox.Items.Add(dr["POSTNAME"].ToString(), dr["TPOST_ID"].ToString());

    }

    }

    }

    }

    我还是会相信,星星会说话,石头会开花,穿过夏天的栅栏和冬天的风雪过后,你终会抵达。
  • 相关阅读:
    【年度回顾】2020,云开发的20个重大更新
    SQL 排序检索数据
    【JVM进阶之路】三:探究虚拟机对象
    【JVM进阶之路】二:Java内存区域
    【JVM进阶之路】一:Java虚拟机概览
    这些不可不知的JVM知识,我都用思维导图整理好了
    计算机网络的七层结构、五层结构和四层结构
    synchronized详解
    Linux内核中I2C总线及设备长啥样?
    C语言中这些预定义宏的不可不会
  • 原文地址:https://www.cnblogs.com/dfxyw/p/5080086.html
Copyright © 2020-2023  润新知