DevExpress控件系列(一):在ASPxGridView Edit Form里任意显示或隐藏Data Columns
DevExpress版本V9.2
有时需要在Edit Form里隐藏掉不需要添加或编辑的columns. 用下面的方法就可以做到了。
代码
1 protected void gv_emailTemplate_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
2 {
3 if (gv_emailTemplate.IsEditing)
4 {
5 GridViewDataColumn dataCol_CreDate = gv_emailTemplate.Columns["cre_date"] as GridViewDataColumn;
6 GridViewDataColumn dataCol_CreUsrId = gv_emailTemplate.Columns["cre_usr"] as GridViewDataColumn;
7 if(dataCol_CreDate !=null)
8 dataCol_CreDate.EditFormSettings.Visible = DevExpress.Web.ASPxClasses.DefaultBoolean.True;
9 if (dataCol_CreUsrId != null)
10 dataCol_CreUsrId.EditFormSettings.Visible = DevExpress.Web.ASPxClasses.DefaultBoolean.True;
11 }
12 }
2 {
3 if (gv_emailTemplate.IsEditing)
4 {
5 GridViewDataColumn dataCol_CreDate = gv_emailTemplate.Columns["cre_date"] as GridViewDataColumn;
6 GridViewDataColumn dataCol_CreUsrId = gv_emailTemplate.Columns["cre_usr"] as GridViewDataColumn;
7 if(dataCol_CreDate !=null)
8 dataCol_CreDate.EditFormSettings.Visible = DevExpress.Web.ASPxClasses.DefaultBoolean.True;
9 if (dataCol_CreUsrId != null)
10 dataCol_CreUsrId.EditFormSettings.Visible = DevExpress.Web.ASPxClasses.DefaultBoolean.True;
11 }
12 }