如何触发customallowsortcolumnnsort

这篇文章主要介绍了DevExpress实现GridView当无数据行时提示消息,需要的朋友可以参考下 本文实例展示了DevExpress实现GridView当无数据行时提示消息的方法,具体步骤如下: 主要功能代码部分如下: /// &summary& /// 设置当没有数据行的提示信息『CustomDrawEmptyForeground』 /// &/summary& /// &param name=&gridView&&GridView&/p
1.girdView line number in the first column shows // Adjusts the width of the first column this.gridView1.IndicatorWidth = 40; private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs
这篇文章主要介绍了DevExpress实现根据行,列索引来获取RepositoryItem的方法,需要的朋友可以参考下 本文实例讲述了DevExpress实现根据行,列索引来获取RepositoryItem的方法,具体方法如下: 主要功能代码如下: /// &summary& /// 根据行,列索引来获取RepositoryItem /// &/summary& /// &param name=&view&&GridView&/param&gt
这篇文章主要介绍了DevExpress实现GridControl列头绘制Checkbox的方法,需要的朋友可以参考下 本文实例展示了DevExpress实现GridControl列头绘制Checkbox的方法,具体实现方法如下: 主要功能代码如下: /// &summary& /// 为列头绘制CheckBox /// &/summary& /// &param name=&view&&GridView&/param& /// &p
这篇文章主要介绍了DevExpress GridControl实现根据RowIndex和VisibleColumnsIndex来获取单元格值,需要的朋友可以参考下 本文实例展示了DevExpress GridControl实现根据RowIndex和VisibleColumnsIndex来获取单元格值的方法,具体如下所示: 主要功能代码如下: /// &summary& /// 根据rowIndex和visibleColumnsIndex来获取单元格可见值 /// &/summary&gt
这篇文章主要介绍了DevExpress实现GridControl删除所有行的方法,对于C#初学者有一定的参考借鉴价值,需要的朋友可以参考下 本文实例讲述了DevExpress实现GridControl删除所有行的方法,希望对读者进行C#程序设计有一定的帮助,具体方法如下: 主要功能代码如下: /// &summary& /// 删除全部行 /// &/summary& /// &param name=&gridView&&GridView&/p
这篇文章主要介绍了DevExpress实现GridControl显示Gif动画的方法,这是比较实用的方法,需要的朋友可以参考下 本文讲述了DevExpress实现GridControl显示Gif动画的方法,是进行C#应用开发中比较重要的功能,具体实现方法如下: 一般来说,如果没有对其进行相关设置,那么GridControl列中gif在编辑状态下,才能显示动画效果,如果要设置列自动显示动画效果,可以进行如下图所示设置: 调用代码如下: gridView.OptionsView.AnimationT
这篇文章主要介绍了DevExpress实现自定义GridControl中按钮文字内容的方法,需要的朋友可以参考下 在一些C#项目的开发中,有时候会使用到GridControl的FindPanel,这样可以很好的对数据进行筛选,可是所展现的按钮文字是英文,如下图所示: 那怎么定义两个按钮问题,以符合项目需求了?本文讲述利用GridLocalizer来实现这一要求的方法.具体步骤如下: 主要功能代码如下: public class BuilderGridLocalizer : GridLocaliz
这篇文章主要介绍了DevExpress实现GridControl根据列选中一行,比较实用的功能,需要的朋友可以参考下 本文实例形式展示了DevExpress实现GridControl根据列选中一行的方法,比较实用的功能,希望能对大家进行项目开发起到一定的借鉴与帮助作用.具体方法如下: 主要功能代码如下: /// &summary& /// 根据列来选中一行 /// &/summary& /// &param name=&gridView&&GridV
这篇文章主要介绍了DevExpress实现GridControl单元格编辑验证的方法,很实用的功能,需要的朋友可以参考下 本文实例演示了DevExpress实现GridControl单元格编辑验证的方法,比较实用的功能,具体方法如下: 主要功能代码如下: /// &summary& /// 自定义单元格验证 /// &/summary& /// &param name=&view&&GridView&/param& /// &par
这篇文章主要介绍了Winform中GridView分组排序功能实现方法,以实例形式详细说明了分组排序的实现方法,并附带完整的DBHelp类代码,是非常实用的技巧,需要的朋友可以参考下 本文实例讲述了Winform中GridView分组排序功能实现方法.分享给大家供大家参考.具体实现方法如下: 一.问题: 由于客户最近要扩充公司的业务,之前基于Winform+web开发混合式的系统已经不能满足他们的需求,需要从新对系统进行分区处理. 考虑到系统模块里面用到的GridView视图比较多,我就结合了D
这篇文章主要介绍了DevExpress中GridControl列转义的实现方法,在项目开发中有一定的实用价值,需要的朋友可以参考下 在一些项目的实际开发过程中,我们有时候需要对GridControl中列值进行转义,譬如1转义成&完成&等等,一般在诸如CustomColumnDisplayText事件中能够轻松完成,为了提高代码复用性,所以需要对CustomColumnDisplayText进行包装.具体方法如下: 主要功能代码如下: /// &summary& /// Cu
这篇文章主要介绍了DevExpress实现GridControl同步列头checkbox与列中checkbox状态,需要的朋友可以参考下 本文实例展示了DevExpress实现GridControl同步列头checkbox与列中checkbox状态的方法,有一定的实用价值,具体方法如下: 主要功能代码如下: /// &summary& /// 同步列头checkbox与列中checkbox状态 /// &/summary& /// &param name=&view
这篇文章主要介绍了DevExpress根据条件设置GridControl RepositoryItem是否可编辑,需要的朋友可以参考下 本文实例展示了DevExpress根据条件设置GridControl RepositoryItem是否可编辑的方法. 一般在C#项目的开发中,并不是每个RepositoryItem都可以编辑,往往是有条件性的,需要譬如当A列等于&AA&的时候,B列才可编辑,实现起来在ShowingEditor事件中最为方便,并且加入toolTip提示显得人性化. 主要
DevExpress是一个比较有名的界面控件套件,提供了一系列的界面控件套件的DotNet界面控件.本文主要介绍我在使用DevExpress控件过程中,遇到或者发现的一些问题解决方案,或者也可以所示一些小的经验总结.总体来讲,使用DevExpress控件,可以获得更高效的界面设计以及更美观的效果.本文主要通过给出相应的例子以及相关界面效果来说明问题,希望大家能够从中获得好的知识和思路. 1. 应用Office2007和Office2010的界面主题 开始使用DevExpress的时候,发现程序界
Using javascript / css implementation GridView alternate row background color, click the line color Ask Bo a few days ago was found in someone clicks GridView question about the issue of line color, suddenly think of a long, long time ago, wrote an a
Using javascript / css to achieve GridView alternate row background color, click the line color Asked a few days ago was found in Bo was asked click on the GridView row color problem, suddenly reminded of a long, long time ago, wrote an article in a
Main code: 1, style &style type=&text/css&& .over { background:#ace1 } .alt { background: # } &/style& 2, js &script type=&text/javascript& src=&../../js/jquery-1.3.2.js&&&/script& &script
1, first set the aspx page EnableEventValidation = &false& as follows: &%@ Page Language=&C#& AutoEventWireup=&true& CodeBehind=&FieldObjSearch.aspx.cs& Inherits=&Unitop.JGXT2010.DAS.FieldObjSearch& Ena
Many users have such needs, such as: Click the button to refresh the data in the GridView, not the page refresh. In fact, the use of javascript to achieve a simple Ajax can be directly achieved. Specific code as follows: &%@ Page Language=&C#&quot
This is the day I spent time before they get to know, and write down the mark about! Front of the code: Note that not using sqldatasource &asp:GridView runat=&server& AllowPaging=&True& PageSize=&6& OnRowDeleting=&Gri
My second asp.net page with a gridview control, paging, simple, and the gridview data source is linked with sqldatasource Reception code: &asp:GridView runat=&server& AllowPaging=&true& PageSize=&6& AutoGenerateColumns=&qu
Repeater control &asp:TemplateColumn& &ItemTemplate& &%# Container.ItemIndex+1 %& &/ItemTemplate& &/asp:TemplateColumn& GridView control &asp:TemplateField HeaderText=& Since adding the FooterText = &since the pa
Repeater control &asp:TemplateColumn& &ItemTemplate& &%# Container.ItemIndex+1 %& &/ItemTemplate& &/asp:TemplateColumn& GridView control &asp:TemplateField HeaderText=& Since adding the FooterText = &since the pa
Sometimes encountered such a situation in which the need to increase the GridView table shows the results of an auto-increment ID column to indicate the serial number of each line. To achieve this function, the first column in the GridView the first
Also for some time I did not write anything, and also because quite a long time before the busy recently what did live there, is not a new task, or not done then the work of the original design and re-start, do a good job on the original development
GridView element from the set Because the set is simple to prevent future forget it for their own inspection stickers 1. Layout: main.xml &?xml version=&1.0& encoding=&utf-8&?& &RelativeLayout xmlns:android=&http://schema
&asp:GridView runat=&server& AutoGenerateColumns=&false& CssClass=&tablecss&& &Columns& &asp:TemplateField HeaderText=& Number & HeaderStyle-CssClass=&aaa& ItemStyle-CssClass=&bbb&
package blog.android. import android.app.A import android.content.C import android.content.I import android.database.C import android.net.U import android.os.B import android.provider.MediaS import andr
If the GridView picture too, successive opening and closing procedures will overflow memory Solution @ Override protected void onPause () ( GridView gridView = (GridView) findViewById (R.id.public_photos); int count = gridView.getCount (); for (int i
Because his careless, lost data in the database is wrong, how will not result in GridView display data, the data source configuration is correct, other operations are also right, depressed most of the day, the last students to find help I watched him
Method 1 1. VIEW layer //==================================================================================== /// &summary& /// The UserInfo of related content is bound to GridView On /// &/summary& /// &returns&&/returns& /// &
GridView is the first choice to achieve the Magical Squares! This article describes how to use the GridView is to achieve the Magical Squares. GridView use of many, the Internet introduced the method is own up to the realization of a ImageAdapter inh
Effect of light sticks In the GridView's RowCreated the incident, which created the event of data lines if (e.Row.RowType == DataControlRowType.DataRow) ( e.Row.Attributes.Add (&onmouseover&, &currertcolor = this.style.backgroundC this
Tr and td Gridview control to display data consolidation solution Through gridview control and code control solution, the code below / / Display data combined tr private static void GroupRows (GridView GridView1, int cellNum, int begin, int end) ( in
Note gridview hidden column In the gridview, some columns do not require the display to the user to see, but do update / delete when they do not need to see the value of the column value as a deletion condition, if you set out visable property, then
&? Xml version = &1.0& encoding = &utf-8&?& &LinearLayout xmlns: android = &/apk/res/android& android: orientation = &vertical& android: layout_width = &fill_parent& andr
Recently to develop a software in the past to do with the BCB out of control that comes with always feel like a toy, before I played tms, although the line of the tms evaluation can still be pricey, but I do not know why the downloaded version of the
Note: If within the gridview radiobutton group name groupname with the same name as method of lines are different, with GroupName = &skytest& view the source code of the static page will know: the value of the two name a group name is different.
GridView control is in use, we often come across for the current row index number of operations carried out by the index. For example, one can get the current set the value of a certain element and so on. The following were intro
Display the information in the report when we may want to show to the form page is as follows: Festival Mobile Unicom Telecommunications Mid-Autumn Festival Scheme 1 Scheme 2 Scheme 1 Scheme 2 Scheme 1 Scheme 2 12 34 56 78 89 34 National day Scheme 1
Reception code: &Asp: GridView runat = &server& Height = &10px& Width = &950px& AllowSorting = &true& OnSorting = &GridView1_Sorting&& &/ Asp: GridView& Notes: AllowSorting = &true& /
Reception code: &asp:GridView runat=&server& Height=&10px& Width=&749px&& &/ asp: GridView& Here we use the GridView data control &asp:LinkButton runat=&server&& data export &/ asp: LinkButton&g
Reception code: &asp:GridView runat=&server& Height=&10px& Width=&749px&& &/ asp: GridView& Here we use the GridView data control &asp:LinkButton runat=&server&& data export &/ asp: LinkButton&g
GridView is a powerful ASP.NET data in control, it's RowDataBound event provides us with a convenient control rows, columns of data channels. To get the current row of a data column, the following methods: 1. Cells [x]. Txt. From the column of text v
Front Code: &asp:GridView runat=&server& Height=&10px& Width=&749px&& &/ asp: GridView& Here we use the GridView data control &asp:LinkButton runat=&server&& Data Export &/ asp: LinkButton& &
GridView is a powerful ASP.NET data in control, it's RowDataBound event provides us with a convenient control rows, columns of data channels. To get the current row of a data column, the following methods: 1. Cells [x]. Txt. From the column to get th
Today, said customer response page when clicking a &garbled&, I know what the problem, and in manually bound GridView DataSource and when paging is enabled, the need for PageIndexChanging event processing. General processing code is as follows:
Customer response, said today that when you click the page &garbled&, I know what the problem is, and manually bind the DataSource in the GridView has paging enabled, the need to PageIndexChanging event processing. General processing code is as
Method One: In the GridView's protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e) ( if (e.Row.RowType == DataControlRowType.DataRow) ( e.Row.Attributes.Add (&onMouseOver&, &SetNewColor (this );&); e.Row.Attrib
Copyright (C) , All Rights Reserved.
版权所有 闽ICP备号
processed in 0.043 (s). 11 q(s)下次自动登录
现在的位置:
& 综合 & 正文
AspxGridView使用手记
AspxGridView使用手记
一、 基本使用方法 4
1.导入Dll文件 4
2.Asp.Net页面控件注册 4
3. Asp.Net页面控件声明 5
4.删除licenses.licx协议文件(盗版) 5
5.功能概述 5
二、 绑定数据(单层) 5
1.使用DataSource属性绑定DataTable 5
2.使用DataSourceID属性绑定SqlDataSource 6
3.使用DataSourceID属性绑定ObjectDataSource 6
4.使用DataSourceID属性绑定LinqDataSource 9
5.使用DataSourceID属性绑定XmlDataSource 10
三、 绑定数据(嵌套树) 10
1.主从数据绑定 10
四、 客户端行维护(新增、修改、删除等) 12
1.编辑状态 12
五、 服务器端行维护(新增、修改、删除等) 13
1.编辑状态 13
六、 数据保存 17
七、 客户端行选择 17
1.选择页面上所有行 17
2.选中指定行或所有行 18
3.获取选中行 18
4.取消页面上所有行的选择 19
5.取消指定行或所有行的选择 19
八、 服务器端行选择 19
1.可选择性设置 19
2.Selection属性 19
九、 客户端行定位 20
1.将焦点转移到编辑行的指定列 20
2.获取焦点行号 20
3.将某行置为可见(未验证) 20
4.跳转到指定页 20
十、 服务器端行定位 21
1.焦点行 21
2.将某行置为可见 21
3.跳转到指定页 21
十一、 客户端数据搜索 21
1.数据过滤 21
十二、 服务端数据搜索 22
1.数据过滤 22
2.数据搜索 22
十三、 分页 23
1.分页条相关属性 23
2.更改分页条按钮属性 26
3.与分页相关操作 26
十四、 客户端排序 26
1.使用SortBy方法排序 26
十五、 服务器端排序 27
1.排序设置 27
2.使用SortBy方法排序 27
3.直接操作GridViewDataColumn排序 28
4.使用GetSortedColumns方法取排序栏位 28
十六、 服务器端数据分组 28
1.数据分组的前提条件 28
2.使用GroupBy方法实现数据分组 28
3.分组的展开与折叠 29
4.判断分组行是否展开 29
5.数据分组的相关设置 29
6.按分组值排序 30
十七、 客户端数据分组 30
1.使用GroupBy方法实现数据分组 30
2.分组的展开与折叠 30
3.判断分组行是否展开 31
4.判断是分组行还是数据行 31
5.用户拖动栏位到分组带实现分组 31
十八、 数据导出 31
1.内置数据导出的前提条件 31
2.支持的数据导出类型 32
3. ASPxGridViewExporter重要属性 32
4.主从ASPxGridView数据导出 32
5.导出到Pdf时中文乱码问题的解决 33
十九、 报表打印 33
二十、 懒加载 33
二十一、 客户端栏位取值与赋值 33
1.使用GetPageRowValues取当前页指定栏位值 33
2.使用GetRowValues取指定行指定栏位值 34
3.使用GetSelectedFieldValues取选中行指定栏位值 34
4.取栏位实例 34
5.使用GetColumnsCount取栏位总数 34
6.使用MoveColumn隐藏和移动栏位 34
7. 使用GetRowKey取行主键值 35
二十二、 服务器端栏位取值与赋值 35
1.取行值 35
2.取列值 36
二十三、 栏位编辑风格 38
1.AspxGridView栏位类型 38
2.GridViewColumn服务器端重要属性 38
3.GridViewColumn服务器端方法 40
4.GridViewCommandColumn:命令按钮列 41
5. GridViewDataColumn:基本数据列 42
6.GridViewDataButtonEditColumn:编辑按钮列 45
7.GridViewDataCheckColumn: 复选框列 45
8.GridViewDataTextColumn:文本列 45
二十四、 栏位格式化 45
二十五、 固定列 45
二十六、 栏位拖动 45
二十七、 栏位合计 46
二十八、 栏位初始值 46
二十九、 栏位可编辑性 46
三十、 栏位数据校验 46
1.行数据校验(编辑状态) 46
三十一、 客户端事件 49
三十二、 服务器端事件 49
1.服务器事件索引 49
2.AutoFilterCellEditorCreate 49
3.AutoFilterCellEditorInitialize 50
4.BeforeGetCallbackResult 50
5.BeforePerformDataSelect 51
6.CancelRowEditing 51
7. CellEditorInitialize 51
7. ClientLayout 52
8. CustomButtonCallback 52
9. CustomCallback 53
10. CustomColumnDisplayText 54
11. CustomColumnGroup 54
12. CustomColumnSort 55
13. CustomDataCallback 56
14. CustomErrorText 57
15. CustomGroupDisplayText 57
16. CustomJSProperties 58
17. CustomSummaryCalculate 58
三十三、 快捷键 59
三十四、 样式 59
1.GridViewStyles重要属性 59
2. GridViewAlternatingRowStyle重要属性 59
三十五、 AspxGridView服务器端重要属性 60
三十六、 AspxGridView服务器端重要方法 60
三十七、 GridViewColumnCollection服务器端重要属性 61
三十八、 AspxGridView客户端重要属性 61
三十九、 AspxGridView客户端常用方法 64
1.PerformCallback 77
四十、 AspxGridView客户端非常用方法 78
四十一、 ASPxClientGridViewColumn(客户端栏位)常用属性 79
四十二、 嵌套AspxGridView的特殊控制 80
1.控制在同一时间只允许一行展开 80
2.SettingsDetail属性设置 80
3.嵌套AspxGridView树展开与折叠(客户端) 80
四十三、 AspxGridView客户端源代码可借鉴点 81
四十四、 AspxGridView服务器端源代码可借鉴点 81
四十五、 BUG 81
四十六、 附录 81
1.格式化标识符 81
2.字符串转为枚举型 83
一、 基本使用方法
1.导入Dll文件
DevExpress.Web.ASPxGridView.v9.1.dll
DevExpress.Web.ASPxEditors.v9.1.dll
DevExpress.Web.v9.1.dll
DevExpress.Data.v9.1.dll文件
2.Asp.Net页面控件注册
&%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.3.0, Culture=neutral, PublicKeyToken=b88da"
Namespace="DevExpress.Web" TagPrefix="dxwgv" %&
&%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.3.0, Culture=neutral, PublicKeyToken=b88da"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %&
&%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.3.0, Culture=neutral, PublicKeyToken=b88da"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %&
&%@ Register Assembly="DevExpress.Data.v9.1, Version=9.1.3.0, Culture=neutral, PublicKeyToken=b88da"
Namespace="DevExpress.Data" TagPrefix="dxwgv" %&
3. Asp.Net页面控件声明
&dxwgv:ASPxGridView ID="ASPxGridView1" runat="server"&
&dxwgv:GridViewDataColumn Caption="LogID" FieldName="LogID" /&
&dxwgv:GridViewDataColumn Caption="发生时间" FieldName="OCCDatetime" /&
&dxwgv:GridViewDataColumn Caption="事件" FieldName="Event" /&
&dxwgv:GridViewDataColumn Caption="类型" FieldName="Type" /&
&dxwgv:GridViewDataColumn Caption="创建人" FieldName="Creator" /&
&dxwgv:GridViewDataColumn Caption="创建日期" FieldName="CreateDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&/Columns&
&/dxwgv:ASPxGridView&
4.删除licenses.licx协议文件(盗版)
5.功能概述
(1)丰富的内置样式
(2)内建的 Ajax 操作
(3)提供客户端 API
(4)内置的排序,分页,分组,过滤功能,无需另外编码
(5)支持多种现场编辑模式: inline, EditForm, EditFormAndDisplayRow, PopupEditForm
(6)可定制模板,支持卡片视图、主从表视图
二、 绑定数据(单层)
可以通过给AspxGridView的DataSource属性或DataSourceID赋值来实现数据绑定。
所支持的数据源类型包括:SqlDataSource、ObjectDataSource、XmlDataSource、AccessDataSource、SiteMapDatasource、LinqDataSource
1.使用DataSource属性绑定DataTable
static string _connectionstring = "Data Source=192.168.1.1 nitial Catalog=SDERP;UID=Password=xxxx”
DataSet currentDs = new DataSet();
using (SqlConnection currentConn = new SqlConnection(_connectionstring))
//获取数据
currentConn.Open();
SqlDataAdapter currentSda = new SqlDataAdapter("select row_number() over(order by LogID) as RowNumber,* from Sys_Log", currentConn);
currentSda.Fill(currentDs, "Sys_Log");
this.ASPxGridView1.DataSource = currentDs.Tables["Sys_Log"];
this.ASPxGridView1.DataBind();
currentConn.Close();
2.使用DataSourceID属性绑定SqlDataSource
&dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="SqlDataSource1"&
&dxwgv:GridViewDataColumn Caption="LogID" FieldName="LogID" /&
&dxwgv:GridViewDataColumn Caption="发生时间" FieldName="OCCDatetime" /&
&dxwgv:GridViewDataColumn Caption="事件" FieldName="Event" /&
&dxwgv:GridViewDataColumn Caption="类型" FieldName="Type" /&
&dxwgv:GridViewDataColumn Caption="创建人" FieldName="Creator" /&
&dxwgv:GridViewDataColumn Caption="创建日期" FieldName="CreateDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&/Columns&
&/dxwgv:ASPxGridView&
&asp:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataReader"
ConnectionString="Data Source=192.168.1.252;Initial Catalog=SDERP;UID=Password=XXXXXXXXX"
SelectCommand="select row_number() over(order by LogID) as RowNumber,* from Sys_Log"&
&/asp:SqlDataSource&
3.使用DataSourceID属性绑定ObjectDataSource
&dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="ObjectDataSource1"&
&dxwgv:GridViewDataColumn Caption="LogID" FieldName="LogID" /&
&dxwgv:GridViewDataColumn Caption="发生时间" FieldName="OCCDatetime" /&
&dxwgv:GridViewDataColumn Caption="事件" FieldName="Event" /&
&dxwgv:GridViewDataColumn Caption="类型" FieldName="Type" /&
&dxwgv:GridViewDataColumn Caption="创建人" FieldName="Creator" /&
&dxwgv:GridViewDataColumn Caption="创建日期" FieldName="CreateDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&/Columns&
&/dxwgv:ASPxGridView&
&asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetAllLog"
typename="AspxGridView.SysLogDAL" /&
其中SysLogDAL.cs代码如下:
using System.Collections.G
using System.L
using System.W
using System.D
using System.Data.SqlC
using System.C
namespace AspxGridView
public class SysLogDAL
static string _connectionstring = "Data Source=192.168.1.252;Initial Catalog=SDERP;UID=Password=XXXXXXXXX";
public static ICollection GetAllLog()
ArrayList al = new ArrayList();
DataSet currentDs = new DataSet();
using (SqlConnection currentConn = new SqlConnection(_connectionstring))
//获取数据
currentConn.Open();
SqlDataAdapter currentSda = new SqlDataAdapter("select * from Sys_Log", currentConn);
currentSda.Fill(currentDs, "Sys_Log");
DataTable dt = currentDs.Tables["Sys_Log"];
foreach (DataRow dr in dt.Rows)
SysLogEntry e = new SysLogEntry();
e.LogID = Int32.Parse(dr["LogID"].ToString());
e.OCCDatetime = DateTime.Parse(dr["OCCDatetime"].ToString());
e.Event = dr["Event"].ToString();
e.Type = dr["Type"].ToString();
e.Creator = dr["Creator"].ToString();
e.CreateDate = DateTime.Parse(dr["CreateDate"].ToString());
e.Remark = dr["Remark"].ToString();
al.Add(e);
currentConn.Close();
其中SysLogEntry.cs代码如下:
using System.Collections.G
using System.L
using System.W
namespace AspxGridView
public class SysLogEntry
public int LogID
public DateTime OCCDatetime
public string Event
public string Type
public string Creator
public DateTime CreateDate
public string Remark
4.使用DataSourceID属性绑定LinqDataSource
&dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="LinqDataSource1"&
&dxwgv:GridViewDataColumn Caption="LogID" FieldName="LogID" /&
&dxwgv:GridViewDataColumn Caption="发生时间" FieldName="OCCDatetime" /&
&dxwgv:GridViewDataColumn Caption="事件" FieldName="Event" /&
&dxwgv:GridViewDataColumn Caption="类型" FieldName="Type" /&
&dxwgv:GridViewDataColumn Caption="创建人" FieldName="Creator" /&
&dxwgv:GridViewDataColumn Caption="创建日期" FieldName="CreateDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&/Columns&
&/dxwgv:ASPxGridView&
&asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="AspxGridView.SysLogDAL" TableName="SysLogEntrys"&
&/asp:LinqDataSource&
其中AspxGridView.SysLogDAL有一个SysLogEntrys的属性,代码如下(其它代码同例3)
public ICollection SysLogEntrys
return this.GetAllLog(); ;
5.使用DataSourceID属性绑定XmlDataSource
&dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="XmlDataSource1"&
&dxwgv:GridViewDataColumn Caption="LogID" FieldName="LogID" /&
&dxwgv:GridViewDataColumn Caption="发生时间" FieldName="OCCDatetime" /&
&dxwgv:GridViewDataColumn Caption="事件" FieldName="Event" /&
&dxwgv:GridViewDataColumn Caption="类型" FieldName="Type" /&
&dxwgv:GridViewDataColumn Caption="创建人" FieldName="Creator" /&
&dxwgv:GridViewDataColumn Caption="创建日期" FieldName="CreateDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&/Columns&
&/dxwgv:ASPxGridView&
&asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Sys_Log.xml"&&/asp:XmlDataSource&
其中Sys_Log.xml文件内容如下
&?xml version='1.0' encoding='gb2312'?&
&row LogID="1" OCCDatetime=" 10:10:11.083" Event="用户【杨东】登陆系统" Type="登陆信息" Creator="sa" CreateDate=" 11:23:08.090" Remark="" /&
三、 绑定数据(嵌套树)
1.主从数据绑定
AspxGridView允许嵌套。
可以通过设置主AspxGridView的ShowDetailRow=true来开启嵌套。&SettingsDetail ShowDetailRow="true" /&。
子AspxGridView定义在父AspxGridView的&Templates&&DetailRow&标签中。
例:Asp.Net代码
&dxwgv:ASPxGridView ID="MasterGrid" runat="server" KeyFieldName="TaskCode" ClientInstanceName="mastergrid" DataSourceID="SqlDataSource1"
&SettingsBehavior AllowMultiSelection="true" /&
&dxwgv:GridViewDataColumn Caption="任务编号" FieldName="TaskCode" /&
&dxwgv:GridViewDataColumn Caption="任务名称" FieldName="TaskName" /&
&dxwgv:GridViewDataColumn Caption="任务类型" FieldName="TaskType" /&
&dxwgv:GridViewDataColumn Caption="计划工时" FieldName="PlanHours" /&
&dxwgv:GridViewDataColumn Caption="计划开始时间" FieldName="PlanBeginDate" /&
&dxwgv:GridViewDataColumn Caption="计划结束时间" FieldName="PlanEndDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&dxwgv:GridViewCommandColumn Caption="操作" Visible="true"&
&UpdateButton Text="保存" Visible="true" /&
&NewButton Text="新增" Visible="true" /&
&CancelButton Text="取消" Visible="true" /&
&ClearFilterButton Text="清除" Visible="true" /&
&SelectButton Text="选择" Visible="true" /&
&/dxwgv:GridViewCommandColumn&
&/Columns&
&SettingsDetail ShowDetailRow="true" /&
&Templates&
&DetailRow&
&dxwgv:ASPxGridView ID="DetailGrid" runat="server" KeyFieldName="ID" ClientInstanceName="detailgrid" DataSourceID="SqlDataSource2"
OnBeforePerformDataSelect="DetailGrid_BeforePerformDataSelect"&
&dxwgv:GridViewDataColumn Caption="ID" FieldName="ID" /&
&dxwgv:GridViewDataColumn Caption="任务编号" FieldName="TaskCode" Visible="false" /&
&dxwgv:GridViewDataColumn Caption="子任务名称" FieldName="ChildTaskName" /&
&dxwgv:GridViewDataColumn Caption="执行人" FieldName="ExecuteUser" /&
&dxwgv:GridViewDataColumn Caption="计划工时" FieldName="PlanHours" /&
&dxwgv:GridViewDataColumn Caption="计划开始时间" FieldName="PlanBeginDate" /&
&dxwgv:GridViewDataColumn Caption="计划结束时间" FieldName="PlanEndDate" /&
&/Columns&
&SettingsDetail IsDetailGrid="true" /&
&/dxwgv:ASPxGridView&
&/DetailRow&
&/Templates&
&/dxwgv:ASPxGridView&
&asp:ObjectDataSource ID="ObjectDataSource_Type" runat="server" SelectMethod="GetUsers"
TypeName="AspxGridView.SysUser"&
&/asp:ObjectDataSource&
&asp:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataSet"
ConnectionString="Data Source=192.168.1.252;Initial Catalog=SDERP;UID=Password=shangdaosoft"
SelectCommand="select * from TM_Task_Master"
&/asp:SqlDataSource&
&asp:SqlDataSource
id="SqlDataSource2"
runat="server"
DataSourceMode="DataSet"
ConnectionString="Data Source=192.168.1.252;Initial Catalog=SDERP;UID=Password=shangdaosoft"
SelectCommand="select * from TM_Task_Detail where TaskCode = @TaskCode"
&SelectParameters&
&asp:SessionParameter Name="TaskCode" SessionField="TaskCode" /&
&/SelectParameters&
&/asp:SqlDataSource&
//子AspxGridView数据绑定
protected void DetailGrid_BeforePerformDataSelect(object sender, EventArgs e)
Session["TaskCode"] = (sender as ASPxGridView).GetMasterRowKeyValue();
四、 客户端行维护(新增、修改、删除等)
1.编辑状态
(1)进入编辑状态
在调用AddNewRow()时或点击【新增】按钮自动进入编辑状态
调用StartEditRow()或点击【编辑】按钮进入编辑状态
(2)取消编辑状态
点击【取消】按钮或【保存按钮】自动取消编辑状态
调用CancelEdit()或UpdateEdit()取消编辑状态
新增行方法:AddNewRow()
function AddNewRow();
调用StartEditRow()使行进入编辑状态
function StartEditRow(visibleIndex : int);
调用DeleteRow方法实现数据删除。
语法:function DeleteRow(visibleIndex : int);
五、 服务器端行维护(新增、修改、删除等)
1.编辑状态
(1)进入编辑状态
在调用AddNewRow()时或点击【新增】按钮自动进入编辑状态
调用StartEditRow()或点击【编辑】按钮进入编辑状态
(2)取消编辑状态
点击【取消】按钮或【保存按钮】自动取消编辑状态
调用CancelEdit()或UpdateEdit()取消编辑状态
(1)在新增、修改、删除行前应设置KeyFieldName属性,否则无法执行行维护。
(2)编辑模式的设置(SettingsEditing.Mode属性,GridViewEditingMode类型)
Inline:在当前行上直接编辑(类似grid)
EditForm:当前行转化为表单,嵌入在行中
EditFormAndDisplayRow:同EditForm,但保留当前行
PopupEditForm: 弹出窗口编辑
(3)新增行的位置
SettingsEditing.NewItemRowPosition属性用来指定新增行的位置。GridViewNewItemRowPosition枚举型,可取值:Top、Bottom。默认为Top。
当取值为Top时,在当前页第一行新增;当取值为Bottom时,在当前页最后一行新增。
(4)如果使用SqlDataSource作为数据源,DataSourceMode=”DataSet”才可更新数据(插入、修改、删除),DataSourceMode=”datareader”时不可更新数据。同时必须配置InsertCommand属性。
(5)新增行方法:AddNewRow()
//新增数据行
protected void btnServerAddRow_Click(object sender, EventArgs e)
string editMode = this.ddlEditMode.SelectedV
GridViewEditingMode gridViewEditingM
switch (editMode)
case "Inline":
gridViewEditingMode = GridViewEditingMode.I
case "EditForm":
gridViewEditingMode = GridViewEditingMode.EditF
case "EditFormAndDisplayRow":
gridViewEditingMode = GridViewEditingMode.EditFormAndDisplayR
case "PopupEditForm":
gridViewEditingMode = GridViewEditingMode.PopupEditF
gridViewEditingMode = GridViewEditingMode.I
this.ASPxGridView1.SettingsEditing.Mode = gridViewEditingM
this.ASPxGridView1.AddNewRow();
新增行后保存数据方法示例
可以直接点内置的【保存】按钮保存数据。
&dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="LogID" DataSourceID="SqlDataSource1"
&dxwgv:GridViewDataColumn Caption="LogID" FieldName="LogID" ReadOnly="false" /&
&dxwgv:GridViewDataColumn Caption="发生时间" FieldName="OCCDatetime" ReadOnly="false" /&
&dxwgv:GridViewDataColumn Caption="事件" FieldName="Event" /&
&dxwgv:GridViewDataColumn Caption="类型" FieldName="Type" /&
&dxwgv:GridViewDataColumn Caption="创建人" FieldName="Creator" /&
&dxwgv:GridViewDataColumn Caption="创建日期" FieldName="CreateDate" /&
&dxwgv:GridViewDataColumn Caption="备注" FieldName="Remark" /&
&dxwgv:GridViewCommandColumn Caption="操作" Visible="true"&
&UpdateButton Text="保存" Visible="true" /&
&NewButton Text="新增" Visible="true" /&
&/dxwgv:GridViewCommandColumn&
&/Columns&
&/dxwgv:ASPxGridView&
&asp:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataSet"
ConnectionString="Data Source=192.168.1.252;Initial Catalog=SDERP;UID=Password=XXXXXXXXX"
SelectCommand="select * from Sys_Log"
InsertCommand="Insert into Sys_Log(OCCDatetime,Event,Type,Creator,CreateDate,Remark) values(@OCCDatetime,@Event,@Type,@Creator,@CreateDate,@Remark)"&
&InsertParameters&
&asp:Parameter Name="OCCDatetime" Type="DateTime" /&
&asp:Parameter Name="Event" Type="String" /&
&asp:Parameter Name="Type" Type="String" /&
&asp:Parameter Name="Creator" Type="String" /&
&asp:Parameter Name="CreateDate" Type="DateTime" /&
&asp:Parameter Name="Remark" Type="String" /&
&/InsertParameters&
&/asp:SqlDataSource&
也可以调用AspxGridView的UpdateEdit方法实现保存。
protected void btnServerSave_Click(object sender, EventArgs e)
this.ASPxGridView1.UpdateEdit();//保存数据
this.ASPxGridView1.CancelEdit();//取消编辑状态
(1)必要条件:数据源必须支持更新(如SqlDataSource配置了UpdateCommand), 必须有主键。
(2)调用StartEdit方法使行进入编辑状态
可以调用UpdateEdit方法保存数据,或调用CancelEdit方法取消编辑状态。
也可以显示出内置的【编辑】按钮让用户点击进入编辑状态。
int firstSelectedRowIndex =-1;
if (this.ASPxGridView1.VisibleRowCount &= 0)
//取选中的第一行
firstSelectedRowIndex++;
if (this.ASPxGridView1.Selection.IsRowSelected(firstSelectedRowIndex))
} while (firstSelectedRowIndex &= 0 || firstSelectedRowIndex &= this.ASPxGridView1.VisibleRowCount);
if (firstSelectedRowIndex == -1)
firstSelectedRowIndex = 0;
int logID = (int)(this.ASPxGridView1.GetRowValues(firstSelectedRowIndex, "LogID"));
this.ASPxGridView1.MakeRowVisible(logID);//使指定行可见
this.ASPxGridView1.FocusedRowIndex = 0;//使指定行成为当前行
this.ASPxGridView1.Selection.UnselectAll();//取消所有行的选择
this.ASPxGridView1.Selection.SelectRow(0);//选中第一行
this.ASPxGridView1.StartEdit(firstSelectedRowIndex);//使指定行进入编辑状态
(1)如果数据源不支持删除则无法执行。必须有主键才能删除(KeyFieldName)。
(2)可调用DeleteRow方法实现数据删除。DeleteRow成功执行后会将数据从数据库中删除。调用DeleteRow方法会首先触发RowDeleting事件(可以在此事件中阻止删除),执行后会触发RowDeleted事件。终端用户还可以通过点击内置的【删除】按钮实现删除。
DeleteRow语法:
Void DeleteRow(int visibleIndex)
参数visibleIndex表示行号。
RowDeleting事件的声明原型:
void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
可以通过修改ASPxDataDeletingEventArgs.Cancel=true来阻止删除。
DevExpress.Web.Data.ASPxDataDeletingEventArgs属性:
Cancel:bool,是否取消删除。可读写。
Keys:OrderedDictionary,要删除行的主键栏位值。只读。
Values: OrderedDictionary,要删除行的非主键(实际上是所有栏位)栏位值。只读。
//删除行前事件
protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
for (int i = 0; i & e.Keys.C i++)
if (Int32.Parse(e.Keys[i].ToString()) & 20000)
e.Cancel =
RowDeleted事件的声明原型:
void ASPxGridView1_RowDeleted(object sender, DevExpress.Web.Data.ASPxDataDeletedEventArgs e)
可以在此事件中获取删除时出现的异常并按自己的方法处理异常,或记录成功删除的行数。
DevExpress.Web.Data.ASPxDataDeletedEventArgs属性包括:
AffectedRecords:int,删除影响到的行数。只读。
Exception:Exception,删除数据期间发生的异常。只读。
ExceptionHandled:bool,是否已处理异常。可读写。
Keys:OrderedDictionary,要删除行的主键栏位值。只读。
Values: OrderedDictionary,要删除行的非主键(实际上是所有栏位)栏位值。只读。
六、 数据保存
调用UpdateEdit方法保存数据。或调用BeginUpdate()和EndUpdate()保存数据。
七、 客户端行选择
1.选择页面上所有行
(1)SelectAllRowsOnPage方法
语法1:void SelectAllRowsOnPage()
语法2:void SelectAllRowsOnPage(bool selected)
参数:selected:选择或取消选择
2.选中指定行或所有行
(1)SelectRows方法
语法1: void SelectRows()//选择所有记录(包括不是当前页的记录)
语法2: void SelectRows(int visibleIndex)//选择指定行(必须设置KeyFieldName)
语法3: void SelectRows(int32[] visibleIndces)
语法4: void SelectRows(int visibleIndex,bool selected)
语法5: void SelectRows(int32[] visibleIndces,bool selected)
例:选中第1-10行
var rows = new Array();
for (var i = 0; i & 10; i++) {
grid.SelectRows(rows);
(2)SelectRowsByKey方法
语法1:void SelectRowsByKey(object key)
语法2:void SelectRowsByKey(Object[] keys)
语法3:void SelectRowsByKey(object key, bool selected);
语法4:void SelectRowsByKey(Object[] keys, bool selected);
3.获取选中行
(1)取选中行数
语法:Int GetSelectedRowCount()
(2)取选中行栏位值
function GetSelectedFieldValues(fieldNames : String,onCallback : ASPxClientGridViewValuesCallback);
function GetSelectedFieldValues(){
var fieldNames = "LogID";
grid.GetSelectedFieldValues(fieldNames, GetSelectedFieldValues_Callback);
function GetSelectedFieldValues_Callback(result) {
var msg="";
if (result.length & 0) {
for (var i = 0; i & result. i++) {
msg = msg + result[i].toString();
alert(msg);
4.取消页面上所有行的选择
(1)UnselectAllRowsOnPage方法
语法:void UnselectAllRowsOnPage()
5.取消指定行或所有行的选择
(1)UnselectRowOnPage方法
语法:function UnselectRowOnPage(visibleIndex : int);
(2)UnselectRows方法
语法1:void UnselectRows();//取消所有行的选择
语法2:void UnselectRows(int visibleIndex);//取消指定行的选择
语法3:void UnselectRows(Int32[] visibleIndices); //取消指定范围内行的选择
(3) UnselectRowsByKey方法
语法1:void UnselectRowsByKey(Object[] keys);
语法2:void UnselectRowsByKey(object key);
八、 服务器端行选择
1.可选择性设置
AspxGridView的SettingsBehavior属性中可以设置是否允许多行选。
This.AspxGridView.SettingsBehavior.AllowSelectByRowClick=true//是否支持单击行选择(V10.0以上)
This.AspxGridView.SettingsBehavior.AllowMultiSelection=true//是否支持多选
2.Selection属性
AspxGridView的Selection属性封装了与行选择有关的属性和方法。它是DevExpress.Web.Data.WebDataSelection类型。
(1) void Selection.SelectAll():选中所有行。不仅仅包括当前页可见的行,还包括非当前页的行。
(2) void Selection.SelectRow(int visibleIndex):选中指定行。该行必须在当前页可见才能被选中。
(3) void Selection.SelectRowByKey(object keyValue):按主键值选中指定行。该行可以不必在当前页。要注意主键值的数据类型应与主键列所定义的数据类型一致。
(4) void Selection.UnselectAll():取消所有行的选择。不仅仅包括当前页可见的行,还包括非当前页的行。
(5) void Selection.UnselectRow(int visibleIndex):取消指定行的选择。该行必须在当前页可见才能被取消选中。
(6) void Selection.UnselectRowByKey(object keyValue):按主键值取消指定行的选择。该行可以不必在当前页。要注意主键值的数据类型应与主键列所定义的数据类型一致。
(7) void Selection.SetSelection(int visibleIndex,bool selected):选中或取消选中指定行。该行必须在当前页可见才能被选择或取消选中。
(8) void Selection.SetSelectionByKey(object keyValue,bool selected):根据主键值选中或取消选中指定行。该行可以不必在当前页。
(9) bool Selection.IsRowSelected(int visibleIndex):判断指定行是否被选中。该行必须在当前页可见。
(10) bool Selection.IsRowSelectedByKey(object keyValue):判断指定主键值对应行是否被选中。该行可以不在当前页。
(11) count属性(int)返回选中行的行数。
九、 客户端行定位
1.将焦点转移到编辑行的指定列
(1)调用SetFocusedRowIndex设置焦点行
function SetFocusedRowIndex(visibleIndex : int);
调用SetFocusedRowIndex方法后将触发FocusedRowChanged事件
(2)调用FocusEditor方法将焦点转移到编辑行的指定列
语法1:FocusEditor(ASPxClientGridViewColumn column);
语法2:FocusEditor(int columnIndex);
语法3:FocusEditor(string columnFieldNameOrId);
2.获取焦点行号
调用GetFocusedRowIndex方法
语法:function GetFocusedRowIndex() :
3.将某行置为可见(未验证)
调用SetClientVisible方法。
4.跳转到指定页
(1)调用GotoPage方法跳转到指定行。
function GotoPage(pageIndex : int);
(2)调用PrevPage方法跳转到前一页。
function PrevPage();
(3)调用NextPage方法跳转到下一页。
function NextPage();
十、 服务器端行定位
AspxGridView的焦点行(当前行)与选择行是有区别的
(1) 获取或设置焦点行可以访问其FocusedRowIndex属性。
(2) 可以通过SettingsBehavior.AllowFocusedRow读取或设置是否允许定位焦点行。
(3) 可以调用AspxGridView的MakeRowVisible方法使指定主键值的行所在页可见,从而立即看到选中或跳转的效果。
int keyValue = (int)(this.ASPxGridView1.GetRowValues(0,"LogID"));
this.ASPxGridView1.MakeRowVisible(keyValue);
this.ASPxGridView1.FocusedRowIndex = 0;
this.ASPxGridView1.Selection.UnselectAll();//取消所有行的选择
this.ASPxGridView1.Selection.SelectRow(0);//选中第一行
2.将某行置为可见
调用MakeRowVisible方法。
3.跳转到指定页
将PageIndex修改为指定页号则可跳转到指定页。
十一、 客户端数据搜索
1.数据过滤
(1)调用AutoFilterByColumn()方法实现过滤。
语法1:void AutoFilterByColumn(ASPxClientGridViewColumn column, string val);
语法2:void AutoFilterByColumn(int columnIndex, string val);
语法3:void AutoFilterByColumn(string columnFieldNameOrId, string val);
不会自动清除之前的过滤条件。
(2)调用ApplyFilter实现过滤。
语法:function ApplyFilter(filterExpression : String);
var filterExpr = document.getElementById("&%=txtFilterExpression.ClientID%&").
grid.ApplyFilter(filterExpr);
会自动清除之前的过滤条件。
(3)调用ClearFilter清除过滤条件
语法:function ClearFilter();
十二、 服务端数据搜索
1.数据过滤
(1)调用AutoFilterByColumn()方法可以实现服务端数据过滤。
AutoFilterByColumn语法:void AutoFilterByColumn(GridViewColumn column,string value)
参数说明:
column:要过滤的栏位
value:要过滤的栏位值。可以使用通配符。
例:数据过滤
protected void btnServerFilter_Click(object sender, EventArgs e)
string filterColumnName = this.ddlFilterColumNames.SelectedV
if (filterColumnName != null)
GridViewColumn col = this.ASPxGridView1.Columns[filterColumnName] as GridViewC
this.ASPxGridView1.AutoFilterByColumn(col, this.txtFilterColumnValue.Text);
(2)通过设置过滤工具条让用户自行输入条件过滤数据
this.ASPxGridView1.Settings.ShowFilterBar = GridViewStatusBarMode.V//过滤状态条模式
this.ASPxGridView1.Settings.ShowFilterRow =//是否过滤行
this.ASPxGridView1.Settings.ShowFilterRowMenu =//是否显示过滤菜单
this.ASPxGridView1.SettingsBehavior.AutoFilterRowInputDelay = 1000;//自动过滤时间间隔(单位:毫秒,默认值:1200)
(3)设置FilterExpression过滤表达式
这是最灵活的一种的方法,可以使用任何有效过滤表达式(包括值比较操作符、逻辑运算符)
LogID & 23955 and Event like '%审核%'
2.数据搜索
(1) FindVisibleIndexByKeyValue
语法:int FindVisibleIndexByKeyValue(object keyValue)
protected void btnFindKeyValue_Click(object sender, EventArgs e)
string keyValue = this.txtFindKeyValue.T
int logID;
if (keyValue.Length & 0 && Int32.TryParse(keyValue,out logID))
int rowIndex = this.ASPxGridView1.FindVisibleIndexByKeyValue(logID);
if (rowIndex &= 0)
this.ASPxGridView1.Selection.UnselectAll();//取消所有行的选择
this.ASPxGridView1.Selection.SelectRow(rowIndex);//选中指定行
this.ASPxGridView1.FocusedRowIndex = rowI
this.ASPxGridView1.MakeRowVisible(logID);
十三、 分页
AspxGridView默认支持分页,默认每页行数(PageSize)是10。如果不想分页,可以设置SettingsPager的Mode=” ShowAllRecords”。可以通过访问SettingsPager读取或更改相关分页属性。
1.分页条相关属性
属性名 数据类型 英文说明 中文说明
AlwaysShowPager bool Gets or sets whether the Pager is displayed within the ASPxGridView when there is only on page. 是否总是显示分页条(即在一页时是否也显示分页条)。可读写
CurrentPageNumberFormat string Gets or sets the pattern used to format the text of the numeric button that corresponds to the selected page. 当前页次数字格式。可读写。类似如下格式:{0:G}
EllipsisMode DevExpress.Web.ASPxPager.PagerEllipsisMode(枚举) Gets or sets how an Ellipsis symbol(s) is drawn to indicate page numbers that are omitted. 获取或设置页码省略模式。可读写。InsideNumeric:中间页码省略,None:不显示省略符,OutsideNumeric:两端页码省略
AllButton DevExpress.Web.ASPxPager.AllButtonProperties Gets the All button’s settings. 取所有分页条上按钮属性.只读
FirstPageButton DevExpress.Web.ASPxPager.FirstButtonProperties Gets the First button's settings. 获取首页按钮属性设置。只读。通常更改其显示文本、可见性、图片。
LastPageButton DevExpress.Web.ASPxPager.LastButtonProperties Gets the Last button's settings. 获取末页按钮属性设置。只读。通常更改其显示文本、可见性、图片。
PrevPageButton DevExpress.Web.ASPxPager.PrevButtonProperties Gets the Previous button's settings. 获取上页按钮属性设置。只读。通常更改其显示文本、可见性、图片。
NextPageButton DevExpress.Web.ASPxPager.NextButtonProperties Gets the Next button's settings. 获取下页按钮属性设置。只读。通常更改其显示文本、可见性、图片。
Mode GridViewPagerMode(枚举) Gets or sets whether page-mode navigation is enabled. 获取或设置是否分页。可读写。取值范围:ShowPager,表示要求分页;ShowAllRecords,显示所有记录,实际上是不分页。
NumericButtonCount Int Gets or sets the maximum number of numeric buttons that can be
displayed within a paginated control. 获取或设置显示在分页条上的数字页码个数。可读写。
PageNumberFormat String Gets or sets the pattern used to format the text of numeric buttons. 数字页码格式。可读写。类似如下格式:{0:G}
PageSize Int Gets or sets the maximum number of rows that can be displayed on a
page. 每页行数。可读写。默认为10.
Position PagerPosition(枚举) Gets or sets the pager's position within an ASPxGridView control. 获取或设置分页条位置。可读写。取值范围:Top,Bottom, TopAndBottom.
SEOFriendly DevExpress.Web.ASPxPager.SEOFriendlyMode(枚举) Gets or sets whether Search-Engine Optimization (SEO) mode is enabled. 获取或设置搜索优化模式。可读写。取值范围:Enabled,启用;Disabled,不启用;CrawlerOnly,自动检测。
ShowDefaultImages bool Gets or sets whether default button images are shown. 获取或设置是否显示缺省的分页图片。可读写。只有本属性设置为true,分页按钮(如首页)的图片才能更改生效。
ShowDisabledButtons Bool Gets or sets whether navigation buttons that are temporarily disabled are shown. 获取或设置当分页按钮无效时是否隐藏。可读写。
ShowNumericButtons Bool Gets or sets whether numeric buttons are visible. 获取或设置数字页码是否可见。可读写。
ShowSeparators Bool Gets or sets whether separators that separate page numbers are shown. 获取或设置页码间是否放置分隔条(|)。可读写。
Summary DevExpress.Web.ASPxPager.SummaryProperties Gets the control's Summary settings. 获取分页控件汇总属性。只读。
Visible Bool Gets or sets whether the pager is visible. 获取或设置分页条是否可见。可读写。
其中以下属性通常会被访问或重置。PageSize、各分页按钮文本。
2.更改分页条按钮属性
分页工具条上一般有首页(FirstPageButton)、上页(PrevPageButton)、下页(NextPageButton)、末页(LastPageButton)按钮。通常会对按钮的文本进行本地化。
this.ASPxGridView1.SettingsPager.FirstPageButton.Text = "首页";
this.ASPxGridView1.SettingsPager.FirstPageButton.Visible =
this.ASPxGridView1.SettingsPager.PrevPageButton.Text = "上一页";
this.ASPxGridView1.SettingsPager.NextPageButton.Text = "下一页";
this.ASPxGridView1.SettingsPager.LastPageButton.Text = "末页";
this.ASPxGridView1.SettingsPager.LastPageButton.Visible =
3.与分页相关操作
(1)跳页: this.ASPxGridView1.PageIndex=&指定页号&
(2)取总页数:this.ASPxGridView1.PageCount
(3)页次改变事件PageIndexChanged
如果AspxGridView是动态绑定数据源,必须在翻页事件(PageIndexChanged)中重新绑定数据,否则翻页后无数据。
void ASPxGridView1_PageIndexChanged(object sender, EventArgs e)
十四、 客户端排序
1.使用SortBy方法排序
语法1:void SortBy(ASPxClientGridViewColumn column);
语法2:void SortBy(int columnIndex);
语法3:void SortBy(string columnFieldNameOrId);
语法4:void SortBy(string columnFieldNameOrId, string sortOrder);
语法5:void SortBy(ASPxClientGridViewColumn column,string sortOrder);
语法6:void SortBy(int columnIndex, string sortOrder);
语法7:void SortBy(int columnIndex, string sortOrder,bool reset);
语法8:void SortBy(ASPxClientGridViewColumn column,string sortOrder, bool reset);
语法9:void SortBy(string columnFieldNameOrId, string sortOrder, bool reset);
语法10:void SortBy(ASPxClientGridViewColumn column,string sortOrder, bool reset, int sortIndex);
语法11:void SortBy(int columnIndex, string sortOrder,bool reset, int sortIndex);
语法12:void SortBy(string columnFieldNameOrId, string sortOrder, bool reset, int sortIndex);
其中参数:
sortOrder:可取Ascending、Descending。
Reset:是否清除以前的排序规则。
(2)点击栏位题头排序。
按住Shift键可以指定多个栏位排序。
十五、 服务器端排序
1.排序设置
必须设置AspxGridView允许排序才可执行真正的排序(SettingsBehavior.AllowSort=true),该选项默认为true。
2.使用SortBy方法排序
语法1.int SortBy(GridViewColumn column,int value)
语法2.ColumnSortOrder SortBy(GridViewColumn column,ColumnSortOrder value)
调用SortBy方法不会自动清除以前的排序栏位,如果不清除之前的排序栏位,则当前栏位会追加到排序栏位列表中。
可以通过以下方法清除以前的排序栏位。
(1) 调用ClearSort方法来清除以前的排序栏位
(2) 遍历栏位的SortIndex属性来确定是否参与过排序及排序的次序(SortIndex=-1表示不排序,另外栏位的SortOrder可获取或设置排序方式)。GridViewColumn. SortIndex=-1。
(3) 调用GridViewColumn.UnSort()方法
protected void btnServerSort_Click(object sender, EventArgs e)
string sortColumn = this.ddlSortColumn.SelectedV
string sortType = this.ddlSortType.SelectedV
GridViewDataColumn sortDataC
DevExpress.Data.ColumnSortOrder sortO
this.ASPxGridView1.SettingsBehavior.AllowSort =
if(sortType == "Desc")
sortOrder = DevExpress.Data.ColumnSortOrder.D
sortOrder = DevExpress.Data.ColumnSortOrder.A
if (sortColumn != null)
this.ASPxGridView1.ClearSort();//清除以前的排序栏位
sortDataColumn = this.ASPxGridView1.Columns[sortColumn] as GridViewDataC
this.ASPxGridView1.SortBy(sortDataColumn, sortOrder);//执行排序
3.直接操作GridViewDataColumn排序
调用GridViewDataColumn.SortAscending()方法正向排序
调用GridViewDataColumn.SortDescending()方法逆向排序
4.使用GetSortedColumns方法取排序栏位
语法:System.Collections.ObjectModel.ReadOnlyCollection&GridViewDataColumn& GetSortedColumns()
System.Collections.ObjectModel.ReadOnlyCollection&GridViewDataColumn& sortedColumnList = this.ASPxGridView1.GetSortedColumns();
StringBuilder msg = new StringBuilder();
for (int i = 0; i & sortedColumnList.C i++)
msg.Append(sortedColumnList[i].FieldName);
string js = "alert('" + msg.ToString()+"')";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "GetSortedColumns", js, true);//在客户端执行脚本
十六、 服务器端数据分组
1.数据分组的前提条件
必须设置ASPxGridViewBehaviorSettings.AllowGroup=true和ASPxGridViewBehaviorSettings.AllowSort=true。
2.使用GroupBy方法实现数据分组
语法1:int GroupBy(GridViewColumn column);
语法2:int GroupBy(GridViewColumn column, int value);
其中参数value表示分组的层次,-1表示取消该栏位的分组。
调用GroupBy方法不会自动清除以前的分组规则,可以调用ClearSort方法或UnGroup方法清除。
例:用一个栏位分组
this.ASPxGridView1.ClearSort();//清空分组
string columnName = this.ddlGroupColumns.SelectedV
GridViewColumn col = this.ASPxGridView1.Columns[columnName];
this.ASPxGridView1.GroupBy(col);//分组
例:用多个栏位分组
this.ASPxGridView1.ClearSort();//清空分组
this.ASPxGridView1.GroupBy(this.ASPxGridView1.Columns[“Event”]);//分组
this.ASPxGridView1.GroupBy(this.ASPxGridView1.Columns[“Type”]);//分组
3.分组的展开与折叠
(1)使用ExpandAll展开所有分组。
语法:void ExpandAll();
(2)使用ExpandRow展开指定分组行。
语法1:void ExpandRow(int visibleIndex);
语法2:void ExpandRow(int visibleIndex, bool recursive);
参数recursive:是否递归。
(3)使用CollapseAll折叠所有分组。
语法:void CollapseAll();
(4)使用CollapseRow折叠指定分组行。
语法1:void CollapseRow(int visibleIndex);
语法2:void CollapseRow(int visibleIndex, bool recursive);
4.判断分组行是否展开
使用IsRowExpanded方法。
语法:bool IsRowExpanded(int visibleIndex);
5.数据分组的相关设置
(1)Setting.GroupFormat用来设置分组行的数据格式(可读写)。
默认是:{0}:{1}{2}。其中{0}表示分组栏位的标签(Caption属性),{1}表示分组栏位值,{2}表示汇总文本。{1}与{2}中间会自动显示括号。只有在&GroupSummary&标签中定义了汇总方式才会在显示其汇总文本。
&GroupSummary&
&dxwgv:ASPxSummaryItem FieldName="OCCDatetime" SummaryType="Count" /&
&/GroupSummary&
(2) Setting. ShowGroupedColumns用来显示已分组的栏位。默认为true。
(3) Setting. ShowGroupedButtons用来显示分组展开按钮(+)。默认为true。
(4) Setting. ShowGroupFooter用来设置分组页脚显示模式(GridViewGroupFooterMode枚举型)。默认为Hidden。可取值:Hidden、VisibleAlways、VisibleIfExpanded。
(5)分组数据间隔。GroupInterval属性。
例:&Settings GroupInterval="DateYear" /&
GroupInterval可赋如下值:Alphabetical、Date、DateMonth、DateRange、DateYear、Default、DisplayText、Value。
6.按分组值排序
this.ASPxGridView1.GroupSummarySortInfo.Clear();
this.ASPxGridView1.GroupSummarySortInfo.AddRange(new ASPxGroupSummarySortInfo("OCCDatetime", this.ASPxGridView1.GroupSummary["OCCDatetime"], ColumnSortOrder.Ascending));
十七、 客户端数据分组
1.使用GroupBy方法实现数据分组
语法1:void GroupBy(int columnIndex);
语法2:void GroupBy(ASPxClientGridViewColumn column);
语法3:void GroupBy(string columnFieldNameOrId);
语法4:void GroupBy(string columnFieldNameOrId, int groupIndex);
语法5:void GroupBy(int columnIndex, int groupIndex);
语法6:void GroupBy(ASPxClientGridViewColumn column, int groupIndex);
语法7:void GroupBy(int columnIndex, int groupIndex,string sortOrder);
语法8:void GroupBy(ASPxClientGridViewColumn column, int groupIndex, string sortOrder);
语法9:void GroupBy(string columnFieldNameOrId, int groupIndex, string sortOrder);
2.分组的展开与折叠
(1)使用ExpandAll展开所有分组。
语法: void ExpandAll();
(2)使用ExpandRow展开指定分组行。
语法1:void ExpandRow(int visibleIndex);
语法2:void ExpandRow(int visibleIndex, bool recursive);
参数recursive:是否递归。
(3)使用CollapseAll折叠所有分组。
语法:void CollapseAll();
(4)使用CollapseRow折叠指定分组行。
语法1:void CollapseRow(int visibleIndex);
语法2:void CollapseRow(int visibleIndex, bool recursive);
3.判断分组行是否展开
使用IsGroupRowExpanded方法。
语法:bool IsGroupRowExpanded(int visibleIndex);
4.判断是分组行还是数据行
(1)判断是否分组行
function IsGroupRow(visibleIndex : int) :
(2)判断是否数据行
function IsDataRow(visibleIndex : int) :
5.用户拖动栏位到分组带实现分组
首先需要显示分组带:&Settings ShowGroupPanel="True" /&
使用鼠标将栏位拖动到分组带即可实现即时分组。将分组栏位拖回题头则取消分组。
十八、 数据导出
1.内置数据导出的前提条件
使用DevExpress.Web.ASPxGridView.Export.ASPxGridViewExporter实现数据导出。注意一定要将该控件放在页面上才可。
应引入以下dll文件:
DevExpress.Utils.v9.1.dll
DevExpress.Web.ASPxGridView.v9.1.Export.dll
DevExpress.XtraPrinting.v9.1.dll
Asp.Net页面注册代码:
&%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1.Export, Version=9.1.3.0, Culture=neutral, PublicKeyToken=b88da"
Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgve" %&
&%@ Register Assembly="DevExpress.XtraPrinting.v9.1, Version=9.1.3.0, Culture=neutral, PublicKeyToken=b88da"
Namespace="DevExpress.XtraPrinting" TagPrefix="dxwgve" %&
Asp.net页面控件声明:
&dxwgve:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server"&
&/dxwgve:ASPxGridViewExporter&
2.支持的数据导出类型
ASPxGridViewExporter支持导出到Csv、Pdf、Rtf、Excel文件,所对应的方法分别为:WriteCsv(WriteCsvResponse)、WritePdf(WritePdfResponse)、WriteRtf(WriteRtfResponse)、WriteXls(WriteXlsResponse)。
在数据导出时通过给ASPxGridViewExporter的GridViewID指定一个AspxGridView控件ID。
例:将所有记录导出到Excel文件
ASPxGridViewExporter1.GridViewID = "ASPxGridView1";
ASPxGridViewExporter1.WriteXlsToResponse("Sys_Log.xls");//导出到Excel
例:将所选记录导出到Pdf文件
ASPxGridViewExporter1.GridViewID = "ASPxGridView1";
ASPxGridViewExporter1. ExportedRowType = GridViewExportedRowType.S
ASPxGridViewExporter1.WritePdfToResponse("Sys_Log.pdf");//导出到pdf
3. ASPxGridViewExporter重要属性
属性名 数据类型 英文说明 中文说明
FileName String Gets or sets the file name to which the grid's data is exported. 导出文件名称。可读写。
GridView AspxGridView Gets the ASPxGridView control to which the ASPxGridViewExporter is
assigned. AspxGridView控件实例。只读。
GridViewID String Gets or sets the programmatic identifier of the associated ASPxGridView control. 需要导出数据的AspxGridView控件ID。可读写。
ExportedRowType GridViewExportedRowType(枚举) Gets or sets which rows should be exported. 导出行范围。可读写。取值范围:All,所有行;Selected,选中行。
4.主从ASPxGridView数据导出
在导出有主从关系的AspxGridView时可设置导出模式(SettingsDetail.ExportMode),取值范围:None(不导出子AspxGridView数据)、Expanded(已展开的子AspxGridView数据)、All(所有子AspxGridView数据)。在导出的文件中主数据下包含了子数据。
//子AspxGridView导出模式
this.MasterGrid.SettingsDetail.ExportMode = (GridViewDetailExportMode)Enum.Parse(typeof(GridViewDetailExportMode), this.ddlExportMode.Text);
ASPxGridViewExporter1.GridViewID = "MasterGrid";
ASPxGridViewExporter1.WriteXlsToResponse("Task.xls");//导出到Excel
5.导出到Pdf时中文乱码问题的解决
可以通过更改ASPxGridViewExporter的Styles.Default.Font.Name来处理中文乱码问题。有中文符号的字体可以正确显示中文。
十九、 报表打印
二十、 懒加载
二十一、 客户端栏位取值与赋值
1.使用GetPageRowValues取当前页指定栏位值
语法;function GetPageRowValues(fieldNames : String,onCallback : ASPxClientGridViewValuesCallback);
function GetPageRowValues() {
var fieldNames = document.getElementById("txtFieldName_GetPageRowValues").
grid.GetPageRowValues(fieldNames, GetPageRowValues_Callback);
function GetPageRowValues_Callback(result) {
var msg = "";
if (result.length & 0) {
for (var i = 0; i & result. i++) {
msg = msg + result[i].toString() + ",";
msg = msg.substring(0, msg.length - 1);
alert(msg);
2.使用GetRowValues取指定行指定栏位值
语法:function GetRowValues(visibleIndex : int,fieldNames : String,
onCallback : ASPxClientGridViewValuesCallback);
3.使用GetSelectedFieldValues取选中行指定栏位值
语法:function GetSelectedFieldValues(fieldNames : String,onCallback : ASPxClientGridViewValuesCallback);
4.取栏位实例
(1)使用GetColumn方法
语法:function GetColumn(columnIndex : int) : ASPxClientGridViewC
(2)使用GetColumnByField方法
语法:function GetColumnByField(columnFieldName : String) : ASPxClientGridViewC
(3)使用GetColumnById方法
语法:function GetColumnById(columnId : String) : ASPxClientGridViewC
5.使用GetColumnsCount取栏位总数
语法:function GetColumnsCount() :
6.使用MoveColumn隐藏和移动栏位
语法1:void MoveColumn(ASPxClientGridViewColumn column);
语法2:void MoveColumn(int columnIndex);
语法3:void MoveColumn(string columnFieldNameOrId);
(2)移动列
语法4:void MoveColumn(ASPxClientGridViewColumn column, int moveToColumnVisibleIndex);
语法5:void MoveColumn(int columnIndex, int moveToColumnVisibleIndex);
语法6:void MoveColumn(string columnFieldNameOrId,int moveToColumnVisibleIndex);
语法7:void MoveColumn(string columnFieldNameOrId,int moveToColumnVisibleIndex, bool
moveBefore);
语法8:void MoveColumn(int columnIndex, int moveToColumnVisibleIndex, bool moveBefore);
语法9:void MoveColumn(ASPxClientGridViewColumn column, int moveToColumnVisibleIndex, bool
moveBefore);
语法10:void MoveColumn(string columnFieldNameOrId,int moveToColumnVisibleIndex, bool
moveBefore, bool moveToGroup);
语法11:void MoveColumn(int columnIndex, int moveToColumnVisibleIndex, bool moveBefore,
bool moveToGroup);
语法12:void MoveColumn(ASPxClientGridViewColumn column, int moveToColumnVisibleIndex, bool
moveBefore, bool moveToGroup);
语法13:void MoveColumn(ASPxClientGridViewColumn column, int moveToColumnVisibleIndex, bool
moveBefore, bool moveToGroup, bool moveFromGroup);
语法14:void MoveColumn(string columnFieldNameOrId,int moveToColumnVisibleIndex, bool
moveBefore, bool moveToGroup, bool moveFromGroup);
语法15:void MoveColumn(int columnIndex, int moveToColumnVisibleIndex, bool moveBefore,
bool moveToGroup, bool moveFromGroup);
7. 使用GetRowKey取行主键值
语法:string function GetRowKey(visibleIndex : int)
二十二、 服务器端栏位取值与赋值
(1) 使用GetDataRow方法取指定行数据
语法:DataRow GetDataRow(int visibleIndex)
visibleIndex:行号。可以是不在当前页上的行。只有通过DataSourceID绑定数据才可获取到数据,如果通过DataSource绑定数据是获取不到值的。
string srowIndex = this.txtGetDataRowIndex.T
if(Int32.TryParse(srowIndex,out rowIndex))
DataRow dr = this.ASPxGridView1.GetDataRow(rowIndex);//取指定行数据
if (dr != null)
string msg = "LogID=" + dr["LogID"].ToString() + ";Event=" + dr["Event"].ToString();
Response.Write(msg);
(2) 使用GetRow方法取指定行数据
语法:object GetRow(int visibleIndex)
visibleIndex:行号。可以是不在当前页上的行。
该函数返回的是object类型,实际类型通常是DataRowView。
(1) 使用GetRowValues方法获取指定栏位值
语法:object GetRowValues(int visibleIndex,parms string fieldnames[])
如果fieldNames只指定一个栏位,GetRowValues将返回object类型,程序员应转换为正确的数据类型。如果fieldNames指定了多个栏位,GetRowValues将返回object[]类型,可以通过is判断返回值。
string srowIndex = this.txtGetDataRowIndex.T
string[] fieldN
string tempFieldN
object tempColumnV
object[] columnV
StringBuilder msg = new StringBuilder();
int count=0;
tempFieldName = this.txtGetValueColumnNames.T
fieldName = tempFieldName.Split(',');//分解字符串到数组
if (Int32.TryParse(srowIndex, out rowIndex))
tempColumnValues = this.ASPxGridView1.GetRowValues(rowIndex, fieldName);//取值
if (tempColumnValues is System.Object[])//返回数组
columnValues = (System.Object[])tempColumnV
count = Math.Min(fieldName.Length, columnValues.Length);
for (int i = 0; i & i++)
msg.Append(fieldName[i] + "=" + columnValues[i].ToString());
else//返回单个值
msg.Append(tempFieldName);
msg.Append("=");
msg.Append(tempColumnValues.ToString());
Response.Write(msg.ToString());
(2) 使用GetRowValuesByKeyValue方法获取指定栏位值
语法:object GetRowValuesByKeyValue(object keyValue,parms string fieldnames[])
GetRowValuesByKeyValue方法与GetRowValues方法类似,只是前者通常主键值找到对应行再获取栏位值而已。
(3) 使用GetSelectedFieldValues方法获取选中行指定栏位值
语法:List&object&GetSelectedFieldValues(parms string fieldnames[])
如果fieldNames只指定一个栏位,GetSelectedFieldValues将返回object列表(各栏位值数组),程序员应转换为正确的数据类型。如果fieldNames指定了多个栏位,GetSelectedFieldValues将返回object[]列表(逐行指定栏位值数组),可以通过is判断返回值。
string tempFieldName = this.txtGetValueColumnNames.T
string[] fieldName = tempFieldName.Split(',');//分解字符串到数组
StringBuilder msg = new StringBuilder();
List&object& tempFieldValues = this.ASPxGridView1.GetSelectedFieldValues(fieldName);//取选中行栏位值
//GetSelectedFieldValues返回值先行后列(类似二维数组)
//行列值行列值行列M值
//行N列值行N列值行N列M值
for (int i = 0; i & tempFieldValues.C i++)
if (tempFieldValues[i] is System.Object[])//返回数组
object[] fieldValues = (object[])tempFieldValues[i];
for (int j = 0; j & fieldValues.L j++)
msg.Append(fieldValues[j].ToString());
msg.Append(tempFieldValues[i].ToString());
Response.Write(msg.ToString());
(4)使用GetCurrentPageRowValues方法获取当前页指定栏位值
语法:List&object&GetCurrentPageRowValues (parms string fieldnames[])
用法类似GetSelectedFieldValues。
二十三、 栏位编辑风格
1.AspxGridView栏位类型
GridViewCommandColumn:命令按钮列
GridViewDataColumn:基本数据列
GridViewDataBinaryImageColumn:二进制图像列
GridViewDataButtonEditColumn:编辑按钮列
GridViewDataCheckColumn: 复选框列
GridViewDataComboBoxColumn:组合框列
GridViewDataDateColumn:日期列
GridViewDataHyperLinkColumn:超链接列
GridViewDataImageColumn:图像列
GridViewDataMemoColumn:大文本列
GridViewDataProgressBarColumn:进度条列
GridViewDataSpinEditColumn:微调掩码列
GridViewDataTextColumn:文本列
其中GridViewCommandColumn与GridViewDataColumn时同级的,都继承自GridViewColumn.
GridViewDataTextColumn类继承自GridViewEditDataColumn,GridViewEditDataColumn继承自GridViewDataColumn,其它数据列直接继承自GridViewDataColumn。
GridViewColumn是一个抽象类,不能将栏位直接声明为GridViewColumn类。
2.GridViewColumn服务器端重要属性
属性名 数据类型 英文说明 中文说明
Caption String Gets or sets the text displayed within the column header. 栏位题头文本。可读写。
CellStyle GridViewCellStyle Gets the style settings used to paint column cells. 栏位样式。只读。
Collection DevExpress.Web.ASPxClasses. Collection Gets the collection to which an item belongs. 栏位所属集合。只读。
FixedStyle GridViewColumnFixedStyle(枚举)
栏位冻结时的样式。可读写。取值范围:Left,固定;None:不固定。
FooterCellStyle GridViewFooterStyle Gets the style settings used to paint footer cells within a column. 页脚栏位样式。只读。
FooterTemplate ITemplate Gets or sets a template for displaying the column's footer cell. 栏位页脚所在单元格模板。可读写。
Grid ASPxGridView Gets the Grid View that owns the current column. 栏位所属AspxGridView。只读。
GroupFooterCellStyle GridViewGroupFooterStyle Gets the style settings used to paint group footer cells within a column. 页脚栏位分组带样式。只读。
HeaderCaptionTemplate ITemplate Gets or sets a template for displaying the column header's caption. 栏位题头模板。可读写。
Index Int Gets or sets the item's index within the collection. 栏位序号。可读写。
Name String Gets or sets the column's programmatic identifier. 栏位名称。可读写。
ShowInCustomizationForm Bool Gets or sets whether the column's header is displayed within the
Customization Window when the column is hidden. 栏位题头(栏位隐藏时)是否显示在自定义窗口中。可读写。
ToolTip String Gets or sets the column header's tooltip text. 微帮助。可读写。
Visible Bool Gets or sets a value that specifies whether the column is visible. 是否显示。可读写。
VisibleIndex Int Gets or sets the column's position among the visible columns within a web control. 显示顺序。可读写。
Width Unit Gets or sets the column's width. 宽度。可读写。
3.GridViewColumn服务器端方法
方法名 语法 英文说明 中文说明
Assign Void Assign(DevExpress.Web.ASPxClasses. CollectionItem source) Copies the public properties from the specified object to the current one. 从指定对象中复制公共属性到当前栏位。
IsClickable bool IsClickable() Indicates whether the column responds to mouse clicks. 判断栏位是否可以响应鼠标单击事件。当栏位有题头或AspxGridView允许排序(SettingsBehavior.AllowSort)或允许栏位拖动(SettingsBehavior.AllowDragDrop)时返回true,否则返回false.
SetColVisible void SetColVisible(bool value)
设置栏位是否可见。等同于Visible属性。
SetColVisibleIndex Void SetColVisibleIndex(int value)
设置栏位显示顺序。等同于VisibleIndex属性。
AutoFilterBy Void AutoFilterBy(string value)
根据指定栏位值自动过滤
(1)Assign方法举例
注意调用Assign方法后当前栏位包括名称、数据都与复制源一致。如果想使复制后数据等某些属性与复制源不同,应在调用本方法后重新改变。通常用来动态创建栏位。
GridViewDataColumn c = (GridViewDataColumn)(this.ASPxGridView1.Columns["Creator"]);
this.ASPxGridView1.Columns["Creator"].Assign(this.ASPxGridView1.Columns["LogID"]);
c.FieldName = "Creator";
c.Name = "Creator";
c.Caption = "Creator";
4.GridViewCommandColumn:命令按钮列
(1)栏位声明示例
&dxwgv:GridViewCommandColumn Caption="选择" Name="IsSelect" ButtonType="Button" ShowSelectCheckbox="true" &
&/dxwgv:GridViewCommandColumn&
&dxwgv:GridViewCommandColumn Caption="操作" Visible="true"&
&UpdateButton Text="保存" Visible="true" /&
&NewButton Text="新增" Visible="true" /&
&CancelButton Text="取消" Visible="true" /&
&ClearFilterButton Text="清除" Visible="true" /&
&SelectButton Text="选择" Visible="true" /&
&/dxwgv:GridViewCommandColumn&
(2)GridViewCommandColumn服务器端重要属性
属性名 数据类型 英文说明 中文说明
AllowDragDrop DefaultBoolean(枚举) Gets or sets whether end-users can drag the column's header. 是否允许栏位拖动。可读写。取值范围:True,False,Default
ButtonType ButtonType(枚举) Gets or sets the command button's type. 按钮类型。可读写。取值范围:Button、Image、Link
CancelButton GridViewComman
&&&&推荐文章:
【上篇】【下篇】

我要回帖

更多关于 onsortcolumn 的文章

 

随机推荐