一。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,控制页码显示个数
protected void ASPxGridView1_PageIndexChanged(object sender, EventArgs e)
{
databind();//只需重新绑定数据即可实现上下翻页
}
新建的列默认是GridViewDataTextColumn类型,选择工具栏的Change To变更列的类型,可以改变新增或修改时的编辑方式。
设置日期类型显示格式,在“行为”PropertiesDateEdit--DisplayFormatString--例如:{0:yyyy年MM月}
当选择了show Group Panel时,FocusedRowChanged事件,重绑定数据,使用时先选中行,再查看
protected void ASPxGridView1_FocusedRowChanged(object sender, EventArgs e)
{
getdata();
}
禁止某一列进行编辑,该列的行为-EditFormSettings-Visible=False
代码中隐藏编辑列的增加,删除,更新按钮
(ASPxGridView1.Columns[编辑列] as GridViewCommandColumn).NewButton .Visible= true;
(ASPxGridView1.Columns[编辑列] as GridViewCommandColumn).DeleteButton.Visible = true;
(ASPxGridView1.Columns[8] as GridViewCommandColumn).UpdateButton .Visible= true;
二。ASPXGridView绑定数据
ASPxGridView1.KeyFieldName = "ID";//指定主键。直接更新数据和子表绑定 需要用到
ASPxGridView1.DataSource = dt.defaultView;//指定Grid的数据
ASPxGridView1.DataBind(); //执行绑定
注意,如果查询结果字段有别名,编辑该字段时,UnboundType应设为Object
三。ASPXGridView查找
过滤数据,查找数据
方式一、展开列标题旁边的过滤清单过滤数据(类似Excel的过滤方式)grid.Settings.ShowHeaderFilterButton = true;过滤清单列出了该列出现的所有数据。还可以自定义过滤清单的内容,用法参阅:http://demos.devexpress.com/ASPxGridViewDemos/Filtering/HeaderFilter.aspx
方式二、在列头显示字段过滤条件输入框 grid.Settings.ShowFilterRow = true; 显示条件判断方式下拉列表grid.Settings.ShowFilterRowMenu = true;
四删除数据
代码中隐藏编辑列的增加,删除,更新按钮
(ASPxGridView1.Columns[编辑列] as GridViewCommandColumn).NewButton .Visible= true;
(ASPxGridView1.Columns[编辑列] as GridViewCommandColumn).DeleteButton.Visible = true;
(ASPxGridView1.Columns[8] as GridViewCommandColumn).UpdateButton .Visible= true;
二。ASPXGridView绑定数据
ASPxGridView1.KeyFieldName = "ID";//指定主键。直接更新数据和子表绑定 需要用到
ASPxGridView1.DataSource = dt.defaultView;//指定Grid的数据
ASPxGridView1.DataBind(); //执行绑定
注意,如果查询结果字段有别名,编辑该字段时,UnboundType应设为Object
三。ASPXGridView查找
过滤数据,查找数据
方式一、展开列标题旁边的过滤清单过滤数据(类似Excel的过滤方式)grid.Settings.ShowHeaderFilterButton = true;过滤清单列出了该列出现的所有数据。还可以自定义过滤清单的内容,用法参阅:http://demos.devexpress.com/ASPxGridViewDemos/Filtering/HeaderFilter.aspx
方式二、在列头显示字段过滤条件输入框 grid.Settings.ShowFilterRow = true; 显示条件判断方式下拉列表grid.Settings.ShowFilterRowMenu = true;
四删除数据
代码中隐藏编辑列的增加,删除,更新按钮
(ASPxGridView1.Columns[编辑列] as GridViewCommandColumn).NewButton .Visible= true;
(ASPxGridView1.Columns[编辑列] as GridViewCommandColumn).DeleteButton.Visible = true;
(ASPxGridView1.Columns[8] as GridViewCommandColumn).UpdateButton .Visible= true;
二。ASPXGridView绑定数据
ASPxGridView1.KeyFieldName = "ID";//指定主键。直接更新数据和子表绑定 需要用到
ASPxGridView1.DataSource = dt.defaultView;//指定Grid的数据
ASPxGridView1.DataBind(); //执行绑定
注意,如果查询结果字段有别名,编辑该字段时,UnboundType应设为Object
三。ASPXGridView查找
过滤数据,查找数据
方式一、展开列标题旁边的过滤清单过滤数据(类似Excel的过滤方式)grid.Settings.ShowHeaderFilterButton = true;过滤清单列出了该列出现的所有数据。还可以自定义过滤清单的内容,用法参阅:http://demos.devexpress.com/ASPxGridViewDemos/Filtering/HeaderFilter.aspx
方式二、在列头显示字段过滤条件输入框 grid.Settings.ShowFilterRow = true; 显示条件判断方式下拉列表grid.Settings.ShowFilterRowMenu = true;
四删除数据
protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
{
e.Cancel = true;//否则,只有刷新页面才能看到删除后的结果
int id =Convert.ToInt32( e.Keys[0]);//获取ID
upd.DelDownFileList(id);//从数据库删除记录
UpLoadFileListBind();//数据表绑定
}
ASPxGridView自带的删除提示,设两个属性即可:
SettingsBehavior. ==> ConfirmDelete=True
SettingsText ==> ConfirmDelete=要提示的字符串
五.更新
取值 用e.NewValues[索引]
并且记得更新数据后 ASPxGridView1.CancelEdit();//结束编辑状态
e.Cancel = true;
bind();
例子: //更新
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
Bill.Message m = new Bill.Message();
//取值 用e.NewValues[索引]
string id = Convert.ToString(e.Keys[0]);
string event_date = e.NewValues[1].ToString();
string event_title = e.NewValues[2].ToString();
string event_description = e.NewValues[3].ToString();
string tag = 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)
{
//动态添加行号非绑定数据
GridViewDataTextColumn dl = new GridViewDataTextColumn();
dl.Caption = "行号";
dl.FieldName = "hh";//该列绑定的字段hh
dl.UnboundType = DevExpress.Data.UnboundColumnType.String;//非数据绑定类型为字符型
dl.PropertiesTextEdit.DisplayFormatString = "c";//显示字符的格式
dl.PropertiesTextEdit.FocusedStyle.ForeColor = System.Drawing.Color.Red;
dl.VisibleIndex = 0;//设置行号列的索引位置
ASPxGridView1.Columns.Insert(0, dl);//把行号列插入0之前
getdata();
ASPxGridView1.Caption = "IP为"+GetClientIP()+"的用户,正在查看网银终端更新内容";
}
在CustomUnboundColumnData事件中
在CustomUnboundColumnData事件中
protected void ASPxGridView1_CustomUnboundColumnData(object sender, ASPxGridViewColumnDataEventArgs e)
{
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
这样就可以轻松做到,不用写代码,绑定多张表
- ASPxGridView 用法
一.ASPxGridView属性:概述设置(Settings) 1.1.Settings <Settings GridLines="Vertical" : 网格样式 Vert ...
- Dev控件用法 aspxTreeList 无刷新 aspxGridView 数据
主要是利用 ASPxTreeList 点击事件回发服务器进行数据重新绑定 ASPxTreeList: <SettingsBehavior ExpandCollapseAction="N ...
- AspxGridView使用手记
AspxGridView使用手记 一. 基本使用方法 4 1.导入Dll文件 4 2.Asp.Net页面控件注册 4 3. Asp.Net页面控件声明 5 4.删除licenses. ...
- ASPxGridView常用总结
目录:一.客户端常用1.常用API2.聚焦行变更事件3.客户端选择多行4.客户端选择行5. 获取选择的行数目6.单击行时,选中行7.通过checkbox 选择行8.选择所有行9.启动编辑框,Conta ...
- EditText 基本用法
title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...
- jquery插件的用法之cookie 插件
一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...
- Java中的Socket的用法
Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- python enumerate 用法
A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...
随机推荐
- MyEclipse-File Serarch时报错:Problems encountered during text search
- iframe替代方案
自己写一个pagelet框架.封装成JSP的Taglib. <tms:view header="common-header" footer="common-foot ...
- css针对(各大浏览器、各版本)调兼容
ie6\ie7\firefox之下各自识别的CSS符号 #1 { color: #333; } /* firefox */ * html #1 { color: #666; } /* IE6 */ * ...
- 容易导致outofmemoryException内存泄漏异常的编码问题
1.System.Drawing方面的类使用问题 System.Drawing用到了很多系统的资源和非托管代码,所以使用的时候要特别小心,注意内存泄漏(Memory Leak) 2.new byte[ ...
- ruby关于flip-flop理解上一个注意点
(..).each do |x| puts x ) .. (x == ) end 上面的flip-flop的用法,你可以理解成 将 大于等于5和小于等于10的数字打印出来,也就是理解成 puts x ...
- JMeter中3种参数值的传递
小伙伴们在使用JMeter的过程中,肯定会遇到参数值传递的问题,下面来和大家总结下,在使用JMeter做压力测试的时候,常见的3种参数值的传递是怎样的. (一)从CSV文件读取要批量输入的变量 假如我 ...
- Performance plugin离线安装
Upload安装plugin Upload安装plugin方式,需要手动下载plugin,然后在Jenkins界面中upload plugin,从而实现安装plugin的目的. 进入Jenkins界面 ...
- 服务器返回数组,data[0]得到的总是不对?如何处理?
我用asp.net MVC 写了服务器代码,返回数组,ajax怎么处理返回的数组内容? 您好,首先用eval将获得的ajax数据转化成json对象并赋值给一个变量. 比如: var obj=eval( ...
- PHP 连接 MSSQL
1 设置 2 php 代码: <?php header('Content-Type:text/html; charset=GBK'); define('DB_HOST','localhost') ...
- Asp.Net 上传图片并生成高清晰缩略图(转)
在asp.net中,上传图片功能或者是常用的,生成缩略图也是常用的.baidu或者google,c#的方法也是很多的,但是一用却发现缩略图不清晰啊,缩略图片太大之类的事情,下面是我在处理图片上的代码, ...