The Htmldatacellprepared event initializes the page when the page is displayed (changes the ID to name)
? The Celleditorinitialize event is the initialization of the page when it is edited (added, modified), such as filling the value into a drop-down list.
///
The name of the department that initializes the grid
///
protected void Grid_userlist_htmldatacellprepared (object sender, Aspxgridviewtabledatacelleventargs e)
{
DataTable dt = new DataTable ();
DT = Customerservicebll. Deptlist (peoid). tables[0];//get the list of all departments under Login Enterprise ID
if (E.datacolumn.fieldname = = "Depid")
{
Datarow[] Row = (datarow[]) dt. Select ("Depid =" + e.cellvalue.tostring () + "");//filter the corresponding department name in DT and put it into the array according to the department ID per line
foreach (DataRow row in row)
{
E.cell.text = row["Depname"]. ToString ();//The value of the depname tag found in the array is assigned to the cell
}
}
}
///
Various initialization when editing
///
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 ());
}
}
}
}
Differences between htmldatacellprepared events and Celleditorinitialize events used in DevExpress in GIRDVIW