Differences between htmldatacellprepared events and Celleditorinitialize events used in DevExpress in GIRDVIW

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.