AspxGridView控件帮助文档(9)
方法名 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) 栏位声明示例
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
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
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字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [互联网资料]2022年厦门大学机电工程系824机械设计
- [互联网资料]东南大学2022年硕士研究生拟录取名单公
- [互联网资料]能源调研报告(精选多篇)
- [互联网资料]初三英语下学期 中考英语 语法填空训练
- [互联网资料]2022内蒙古选调生行测常识备考:新事物
- [互联网资料]自驾必备!在新西兰租什么样的车自驾游
- [互联网资料]佛教素食菜谱44页未完
- [互联网资料]盈利能力分析外文翻译
- [互联网资料]2022年南昌航空大学音乐学院736马克思
- [互联网资料]优选外贸跟单实习报告总结(精品版)
- [互联网资料]银行新员工培训总结
- [互联网资料]2_year_visa_new_guidance_190316
- [互联网资料]天津市五校宝坻一中静海一中杨村一中芦
- [互联网资料]2007--2008学年第一学期高三数学宁波市
- [互联网资料]Chromatic framework for vision in ba
- [互联网资料]幼儿园大班上学期美术教案《心愿树》含
- [互联网资料]2022年华中农业大学信息学院820微型计
- [互联网资料]硬盘坏道的表现 __硬盘使用久了
- [互联网资料]江苏省2016年会计从业资格考试《会计基
- [互联网资料]公共场所卫生监督试卷全解
- 高级英语第一册所有修辞方法及例子总结
- 综合交通枢纽规划与城市发展
- 沃尔玛的企业文化案例分析
- 美国Thanksgiving Day 感恩节 介绍
- PEP六年级英语上册Unit6How do you fee
- 最齐全的中国大型商场购物中心名单
- 数据结构实验报告八—哈夫曼编译码
- 杭州市余杭区人民政府(通知)
- 七年级语文成语运用专项训练
- 微观经济学第三章 消费者行为 课后习题
- 对_钱学森之问_的思考
- Excel_三级联动_下拉菜单
- 办公用品需求计划申请表
- 对外汉语教材必须要知道的发展史
- 挑战杯大学生学术科技作品竞赛作品申报
- 举办民办教育培训机构应具备下列条件
- 太阳能路灯项目设计方案
- 2013年八年级上最新人教版新教材Unit3I
- 【历史】 6-4 《近代科学之父牛顿》 课
- 高中生物《第四章 第二节 探讨加酶洗衣




