组合框列(GridViewDataComboBoxColumn)
protected void grid_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) {
// 用下拉框展示国家下的所有城市 绑定数据源
if(grid.IsEditing && e.Column.FieldName != \&& !grid.IsNewRowEditing) {
ASPxComboBox combo = e.Editor as ASPxComboBox;
string country = (string)grid.GetRowValuesByKeyValue(e.KeyValue, \ FillCityCombo(combo, country); } }
命令按钮列(GridViewCommandColumn)
OnRowDeleting=\OnRowUpdating=\OnRowInserting=\ 一种是添加图片的 一种就只这种标准的:
代码详见《ASPxGridView.DataBind》 复选框列
protected void gv_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e)
{
if (e.ButtonID == \ {
long fileId = Convert.ToInt64(gv.GetRowValues(e.VisibleIndex, \ string fileName = gv.GetRowValues(e.VisibleIndex, \ string filePath = Common.Config.Path.PhysicalUploadFolder + gv.GetRowValues(e.VisibleIndex, \ System.IO.File.Delete(filePath); using (DbFile db = new DbFile()) db.DelFile(fileId); ShowData(this.FileBatchId); } } “复制行”按钮
protected void grid_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e) {
if(e.ButtonID == \ {
copiedValues = new Hashtable(); foreach(string fieldName in copiedFields)
copiedValues[fieldName] = grid.GetRowValues(e.VisibleIndex, fieldName);
grid.AddNewRow(); } }
protected void grid_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) {
if(copiedValues != null)
foreach(string fieldName in copiedFields)
e.NewValues[fieldName] = copiedValues[fieldName]; }
非绑定列(GridViewDataTextColumn)
// Total = UnitPrice * Quantity if(e.Column.FieldName == \ {
decimal price = (decimal)e.GetListSourceFieldValue(\ int quantity = Convert.ToInt32(e.GetListSourceFieldValue(\ e.Value = price * quantity; } }
模板列(GridViewDataTextColumn)
onhtmlrowcreated=\
protected void grid_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e) {