教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 互联网资料 >

AspxGridView控件帮助文档(9)

来源:网络收集 时间:2026-08-26
导读: 方法名 Assign 语法 Void CollectionItem source) 中文说明 从指定对象中复制公共属 Assign(DevExpress.Web.ASPxClasses. 性到当前栏位。 AutoFilterBy GroupBy SortAscending UnGroup UnSort Void AutoFilterBy(st

方法名 Assign

语法 Void

CollectionItem source)

中文说明

从指定对象中复制公共属

Assign(DevExpress.Web.ASPxClasses. 性到当前栏位。

AutoFilterBy GroupBy SortAscending UnGroup UnSort Void AutoFilterBy(string value) void GroupBy() void SortAscending() void UnGroup() Void UnSort() 根据指定栏位值自动过滤 按当前栏位分组。可以调用UnGroup方法打散分组。 按当前栏位值正序排序 按当前栏位值倒序排序 取消当前栏位分组 取消当前栏位排序 SortDescending Void SortDescending()

6.GridViewDataButtonEditColumn:编辑按钮列 (1) 栏位声明示例 (2) 独特属性 GridViewDataButtonEditColumn继承自GridViewDataColumn,它包括以下独特属性: 属性名 PropertiesButtonEdit 数据类型 ButtonEditProperties 中文说明 栏位编辑器属性 7.GridViewDataCheckColumn: 复选框列 8.GridViewDataTextColumn:文本列

15.AspxGridView列的个性设置

一、如何设置固定列

AspxGridView的固定列是通过设置栏位的FixedStyle=”Left”来实现的。 Asp.net中设置:FixedStyle=”Left”

C#中设置:FixedStyle = GridViewColumnFixedStyle.Left

二、如何设置可拖动列

设置SettingsBehavior.AllowDragDrop=true则允许栏位拖动。 调用客户端方法MoveColumn可在前台实现代码拖动。支持用户使用鼠标拖动栏位。

三、如何设置列合计值

AspxGridView的汇总数据是显示在Footer带上的,必须设置

Settings.ShowFooter=true。直接显示在栏位下方。 可以将汇总信息定义在标签中。 例:

AspxGridView内置的聚合函数包括:Sum、Min、Max、Count、Average、Custom、None。

四、如何为列设置初始值

AspxGridView要设置栏位新增时初始值需要扩充其InitNewRow事件。代码的主要功能是给e.NewValues[列名称]赋值。 事件原型:

protected void ASPxGridView1_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)

DevExpress.Web.Data.ASPxDataInitNewRowEventArgs属性: NewValues:System.Collections.Specialized.OrderedDictionary类型

例:

//设置栏位初始值

rotected void ASPxGridView1_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) {

e.NewValues[\}

16.AspxGridView之数据校验

行数据校验(编辑状态)

调用DoRowValidation()可以进行行数据校验。它实际上是触发RowValidating事件编写代码实现数据校验的。DoRowValidation方法对浏览状态的行无效,可以通过获取AspxGridView的IsEditing属性判断是否进入编辑状态。

RowValidating事件原型:

void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)

DevExpress.Web.Data.ASPxDataValidationEventArgs构造函数: public ASPxDataValidationEventArgs(bool isNew);

DevExpress.Web.Data.ASPxDataValidationEventArgs属性:

Errors: Dictionary,行错误集合,只读。 HasErrors:bool,待处理的行是否有错。只读。 IsNewRow:bool,待处理的行是否新增行。只读。

Keys:OrderedDictionary,要删除行的主键栏位值。只读。

NewValues: OrderedDictionary,要删除行的非主键(实际上是所有栏位)栏位新值。只读。

OldValues: OrderedDictionary,要删除行的非主键(实际上是所有栏位)栏位原值。只读。

RowError:string,行错误信息。可读写。

通常在RowValidating事件中检查栏位值是否有效,如果无效,应抛出异常。 例:

//行数据检验事件

protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) {

//是否新增行 if (e.IsNewRow) {

if (e.NewValues[\ {

e.Errors.Add(this.ASPxGridView1.Columns[\事件名称不可为空\ e.RowError = \事件名称不可为空\ throw new Exception(\事件名称不可为空\ } } }

通常在HtmlRowPrepared事件中检查行是否有效并以不同的颜色来显示未通过校验的行。

通常在StartRowEditing事件中调用DoRowValidation方法触发数据校验。

以下是官方的示例代码:

using DevExpress.Web.ASPxGridView; using System.Collections.Generic;

protected void grid_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) {

// Checks for null values.

foreach (GridViewColumn column in grid.Columns) {

GridViewDataColumn dataColumn = column as GridViewDataColumn; if (dataColumn == null) continue;

if (e.NewValues[dataColumn.FieldName] == null) e.Errors[dataColumn] = \ }

// Displays the error row if there is at least one error. if (e.Errors.Count > 0) e.RowError = \

if (e.NewValues[\

e.NewValues[\ AddError(e.Errors, grid.Columns[\ \ }

if (e.NewValues[\

e.NewValues[\ AddError(e.Errors, grid.Columns[\ \ }

if (string.IsNullOrEmpty(e.RowError) && e.Errors.Count > 0) e.RowError = \}

void AddError(Dictionary errors, GridViewColumn column, string errorText) { if(errors.ContainsKey(column)) return; errors[column] = errorText; }

protected void grid_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) {

// Checks whether the generated row has the errors.

bool hasError = e.GetValue(\ hasError = hasError || e.GetValue(\ hasError = hasError || e.GetValue(\ // If the row has the error(s), its text color is set to red. if (hasError)

e.Row.ForeColor = System.Drawing.Color.Red; }

protected void grid_StartRowEditing(object sender,

DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) { // Validates the edited row if it isn't a new row,. if (!grid.IsNewRowEditing) grid.DoRowValidation(); }

17.AspxGridView服务器事件列表

2.AutoFilte …… 此处隐藏:3054字,全部文档内容请下载后查看。喜欢就下载吧 ……

AspxGridView控件帮助文档(9).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/444171.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)