• 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());

    }

    }

    }

    }

    我还是会相信,星星会说话,石头会开花,穿过夏天的栅栏和冬天的风雪过后,你终会抵达。
  • 相关阅读:
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    HTML5
    53.Maximum Subarray
  • 原文地址:https://www.cnblogs.com/dfxyw/p/5080086.html
Copyright © 2020-2023  润新知