码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-12-27 16:03:12      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

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

}

}

}

}

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

标签:

原文地址:http://www.cnblogs.com/dfxyw/p/5080086.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!