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

}

}

}

}

转载于:https://www.cnblogs.com/dfxyw/p/5080086.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值