企部核对结果\PropertiesMemoEdit-Rows=\EditFormSettings-ColumnSpan=\/>
// 普通状态下的命令按钮显隐
protected void gv_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e) {
if (!gv.IsEditing && e.RowType == DevExpress.Web.ASPxGridView.GridViewRowType.Data) {
bool isAdmin = Common.IsInRoles(new string[] { WZWF.DAL.Roles.Admin });
string unit = gv.GetRowValues(e.VisibleIndex, \ bool isAuth = Common.IsInRoles( unit,
WZWF.DAL.Roles.EnterpriseDepartment, WZWF.DAL.Roles.MaintainDepartment ); // 修改按钮
WebControl btnModify = e.Row.Cells[0].Controls[0] as WebControl; btnModify.Visible = isAuth; // 新建按钮
WebControl btnAddNew = e.Row.Cells[0].Controls[1] as WebControl;
btnAddNew.Visible = isAdmin; // 删除按钮
WebControl btnDelete = e.Row.Cells[0].Controls[2] as WebControl; btnDelete.Visible = isAdmin; } }
// 编辑状态下的控件访问权限控制
// 管理员:unit, result, md_cmt, ed_cmt // 政企部:ed_cmt
// 网络维护部:result, md_cmt
protected void grid_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) {
if (gv.IsEditing) {
// 受理单位下拉框
if (e.Column.FieldName == \ {
ASPxComboBox combo = e.Editor as ASPxComboBox;
using (DbClean db = new DbClean()) {
combo.DataSource = db.ListUnits(); combo.TextField = \ combo.ValueField = \ combo.DataBind(); } }
// 新建状态除了id以外都可以编辑
if (gv.IsNewRowEditing) {
e.Editor.ReadOnly = (e.Column.FieldName == \ }
// 修改状态下根据角色可编辑部分数据
else {
e.Editor.ReadOnly = true;
if (e.Column.FieldName == \
e.Editor.ReadOnly = !Common.IsInRoles(WZWF.DAL.Roles.Admin);
else if (e.Column.FieldName == \|| e.Column.FieldName == \
e.Editor.ReadOnly = !Common.IsInRoles(WZWF.DAL.Roles.Admin, WZWF.DAL.Roles.MaintainDepartment);
else if (e.Column.FieldName == \
e.Editor.ReadOnly = !Common.IsInRoles(WZWF.DAL.Roles.Admin, WZWF.DAL.Roles.EnterpriseDepartment); } }
// 可编辑控件设置背景色
e.Editor.BackColor = e.Editor.ReadOnly ? Color.White : Color.LightYellow; }
// 删除
protected void gv_RowDeleting(object sender, ASPxDataDeletingEventArgs e) {
int id = Convert.ToInt32(e.Keys[0]); using (DbClean db = new DbClean()) db.DelBasicNet(id);
e.Cancel = true; gv.CancelEdit();
ShowData(ViewState[\ }
// 更新
protected void gv_RowUpdating(object sender, ASPxDataUpdatingEventArgs e) {
string unit = Convert.ToString(e.NewValues[\
string result = Convert.ToString(e.NewValues[\ string edCmt = Convert.ToString(e.NewValues[\ if (gv.IsEditing) {
int id = Convert.ToInt32(e.Keys[0]); using (DbClean db = new DbClean()) db.ModBasicNet(id, ...); }
e.Cancel = true; gv.CancelEdit();
ShowData(ViewState[\ } // 新增
protected void grid_InitNewRow(object sender, ASPxDataInitNewRowEventArgs e) {
e.NewValues[\= Page.User.Identity.Name; e.NewValues[\= System.DateTime.Now; }
protected void gv_RowInserting(object sender, ASPxDataInsertingEventArgs e) {
string unit = Convert.ToString(e.NewValues[\
string result = Convert.ToString(e.NewValues[\ string edCmt = Convert.ToString(e.NewValues[\ if (gv.IsNewRowEditing) {
using (DbClean db = new DbClean()) db.AddBasicNet(.....); }
e.Cancel = true; gv.CancelEdit();
ShowData(ViewState[\ }
(四)数据源
-- DataSource 支持的数据源 -- DataTable
-- IList
-- BindingList
-- XXXDataSource
--------------------------------------------------------- DataTable
grid.DataSource = dt; grid.DataBind(); IList
int articleId = Convert.ToInt32(Request.QueryString[\
IList
this.gvImages.KeyFieldName = \ this.gvImages.DataSource = images; this.gvImages.DataBind();
BindingList
private void CreateQuotes() {
BindingList res = new BindingList
(); foreach(string name in names) {
Quote q = new Quote(name);
q.Value = (decimal)GetRandom().Next(800, 2000) / (decimal)10; res.Add(q); }
Session[\= res; }
AccessDataSource
SelectCommand=\* FROM [Customers]\ DeleteCommand=\FROM [Customers] WHERE [CustomerID] = ?\ InsertCommand=\INTO [Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\ UpdateCommand=\[Customers] SET [CompanyName] = ?, [ContactName] = ?, [ContactTitle] = ?, [Address] = ?, [City] = ?, [Region] = ?, [PostalCode] = ?, [Country] = ?, [Phone] = ?, [Fax] = ? WHERE [CustomerID] = ?\ />

