ASPxGridview使用总结DEVExpress.docx

上传人:b****3 文档编号:3060406 上传时间:2022-11-17 格式:DOCX 页数:12 大小:21.58KB
下载 相关 举报
ASPxGridview使用总结DEVExpress.docx_第1页
第1页 / 共12页
ASPxGridview使用总结DEVExpress.docx_第2页
第2页 / 共12页
ASPxGridview使用总结DEVExpress.docx_第3页
第3页 / 共12页
ASPxGridview使用总结DEVExpress.docx_第4页
第4页 / 共12页
ASPxGridview使用总结DEVExpress.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

ASPxGridview使用总结DEVExpress.docx

《ASPxGridview使用总结DEVExpress.docx》由会员分享,可在线阅读,更多相关《ASPxGridview使用总结DEVExpress.docx(12页珍藏版)》请在冰豆网上搜索。

ASPxGridview使用总结DEVExpress.docx

ASPxGridview使用总结DEVExpress

ASPxGridview使用总结(DEVExpress)

一。

ASPXGridView外观显示

属性:

Caption----列的标题(

KeyFieldName----数据库字段

SEOFriendly是否启用搜索引擎优化

Summary指定分页汇总信息的格式

Setting节点的ShowFilterRow=True设置快速查找功能

SettingsBehavior.AllowFocusedRow=true高亮选中的行,即选中行变色

SettingsBehavior.AllDragDrop=false禁止拖动标题列头

SettingsBehavior.AllowSort实现列头点击后是否可以排序

SettingsPager.ShowEmptyDataRows=True;当数据行为空时,显示空行

SettingsPager.PageSize每页显示的记录总数

AllButton.Text“全部数据显示”按钮的文本

AllButton.Visible是否显示“全部数据显示”按钮

FirstPageBuotton/LastPageButton/NextPageButton/PrevPageButton/对应首页、末页、下页、上页,设置同上。

NumericButtonCount最小值为1,控制页码显示个数

protectedvoidASPxGridView1_PageIndexChanged(objectsender,EventArgse)

{

databind();//只需重新绑定数据即可实现上下翻页

}

新建的列默认是GridViewDataTextColumn类型,选择工具栏的ChangeTo变更列的类型,可以改变新增或修改时的编辑方式。

设置日期类型显示格式,在“行为”PropertiesDateEdit--DisplayFormatString--例如:

{0:

yyyy年MM月}

 

当选择了showGroupPanel时,FocusedRowChanged事件,重绑定数据,使用时先选中行,再查看

protectedvoidASPxGridView1_FocusedRowChanged(objectsender,EventArgse)

{

getdata();

}

禁止某一列进行编辑,该列的行为-EditFormSettings-Visible=False

代码中隐藏编辑列的增加,删除,更新按钮

(ASPxGridView1.Columns[编辑列]asGridViewCommandColumn).NewButton.Visible=true;

(ASPxGridView1.Columns[编辑列]asGridViewCommandColumn).DeleteButton.Visible=true;

(ASPxGridView1.Columns[8]asGridViewCommandColumn).UpdateButton.Visible=true;

每行都有一个CHECKBOX,可以动态选择,只需要这样即可

GridViewCommandColumnShowSelectCheckbox="true"VisibleIndex="8">

GridViewCommandColumn>

....其它列

二。

ASPXGridView绑定数据

ASPxGridView1.KeyFieldName="ID";//指定主键。

直接更新数据和子表绑定需要用到

ASPxGridView1.DataSource=dt.defaultView;//指定Grid的数据

ASPxGridView1.DataBind();//执行绑定

注意,如果查询结果字段有别名,编辑该字段时,UnboundType应设为Object

三。

ASPXGridView查找

过滤数据,查找数据

方式一、展开列标题旁边的过滤清单过滤数据(类似Excel的过滤方式)grid.Settings.ShowHeaderFilterButton=true;过滤清单列出了该列出现的所有数据。

还可以自定义过滤清单的内容,用法参阅:

方式二、在列头显示字段过滤条件输入框grid.Settings.ShowFilterRow=true;显示条件判断方式下拉列表grid.Settings.ShowFilterRowMenu=true;

四删除数据

protectedvoidASPxGridView1_RowDeleting(objectsender,DevExpress.Web.Data.ASPxDataDeletingEventArgse)

{

e.Cancel=true;//否则,只有刷新页面才能看到删除后的结果

intid=Convert.ToInt32(e.Keys[0]);//获取ID

upd.DelDownFileList(id);//从数据库删除记录

UpLoadFileListBind();//数据表绑定

}

ASPxGridView自带的删除提示,设两个属性即可:

SettingsBehavior.==>ConfirmDelete=True

SettingsText==>ConfirmDelete=要提示的字符串

五.更新

取值用e.NewValues[索引]

并且记得更新数据后ASPxGridView1.CancelEdit();//结束编辑状态

e.Cancel=true;

bind();

例子:

//更新

protectedvoidASPxGridView1_RowUpdating(objectsender,DevExpress.Web.Data.ASPxDataUpdatingEventArgse)

{

Bill.Messagem=newBill.Message();

//取值用e.NewValues[索引]

stringid=Convert.ToString(e.Keys[0]);

stringevent_date=e.NewValues[1].ToString();

stringevent_title=e.NewValues[2].ToString();

stringevent_description=e.NewValues[3].ToString();

stringtag=e.NewValues[4].ToString();

m.Message_update(id,event_date,event_title,event_description,tag);

ASPxGridView1.CancelEdit();//结束编辑状态

e.Cancel=true;

bind();

}

六排序

在BeforeColumnSortingGrouping事件中重新绑定一下数据

七.分页

PageIndexChanged事件里重新绑定一下数据

--------------------------------------------------------------------------------

1.动态添加非数据绑定列,例子:

动态添加行号列

if(!

IsPostBack)

{

//动态添加行号非绑定数据

GridViewDataTextColumndl=newGridViewDataTextColumn();

dl.Caption="行号";

dl.FieldName="hh";//该列绑定的字段hh

dl.UnboundType=DevExpress.Data.UnboundColumnType.String;//非数据绑定类型为字符型

dl.PropertiesTextEdit.DFormatString="c";//显示字符的格式

dl.PropertiesTextEdit.FocusedStyle.ForeColor=System.Drawing.Color.Red;

dl.VisibleIndex=0;//设置行号列的索引位置

ASPxGridView1.Columns.Insert(0,dl);//把行号列插入0之前

getdata();

ASPxGridView1.Caption="IP为"+GetClientIP()+"的用户,正在查看网银终端更新内容";

}

在CustomUnboundColumnData事件中

protectedvoidASPxGridView1_CustomUnboundColumnData(objectsender,ASPxGridViewColumnDataEventArgse)

{

if(e.Column.FieldName=="hh"&&e.IsGetData)

e.Value=(e.ListSourceRowIndex+1).ToString();

}

2.ASPxComboBox列的相关操作

简单的方法是

1.FiledName写主表与此字段有关联外键字段:

例如uid

2.在PropertiesCombobox下面找这几个属性:

然后在客户姓名的这一列的DataSourceId,给它绑定上我们字表的ObjectDataSource

在TextField设置字段名称,例如:

name

在ValueField设置名称应该就是字表的主键(也就是主表引用字表的外键),例如:

uid

这样就可以轻松做到,不用写代码,绑定多张表

手写代码的方法来绑定ASPxComboBox

在aspx中将该列的-行为-PropertiesComboBox-ValuesType设为System.String避免ComboBox出现无法选中的现象

usingDevExpress.Web.ASPxGridView;

usingDevExpress.Web.ASPxEditors;

//在页面加载时,给combox列赋值,这里的workgroupID是在ASPxGridview中的Combox列绑定的字段

(ASPxGridView1.Columns["WorkgroupID"]asGridViewDataComboBoxColumn).PropertiesComboBox.ValueType=typeof(int);

fangqm.Netbank.Core.groupInfogroup=newfangqm.Netbank.Core.groupInfo();

DataTabledt=group.groupSelectAll();//table

for(inti=0;i

{

intid=Convert.ToInt32(dt.Rows[i][0]);

stringv=dt.Rows[i][1].ToString();

(ASPxGridView1.C

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1