一。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用法的更多相关文章

  1. ASPxGridView 用法

    一.ASPxGridView属性:概述设置(Settings) 1.1.Settings <Settings GridLines="Vertical" : 网格样式 Vert ...

  2. Dev控件用法 aspxTreeList 无刷新 aspxGridView 数据

    主要是利用 ASPxTreeList 点击事件回发服务器进行数据重新绑定 ASPxTreeList: <SettingsBehavior ExpandCollapseAction="N ...

  3. AspxGridView使用手记

    AspxGridView使用手记   一.  基本使用方法  4 1.导入Dll文件   4 2.Asp.Net页面控件注册 4 3. Asp.Net页面控件声明    5 4.删除licenses. ...

  4. ASPxGridView常用总结

    目录:一.客户端常用1.常用API2.聚焦行变更事件3.客户端选择多行4.客户端选择行5. 获取选择的行数目6.单击行时,选中行7.通过checkbox 选择行8.选择所有行9.启动编辑框,Conta ...

  5. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  6. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  7. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  8. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  9. python enumerate 用法

    A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...

随机推荐

  1. SVN中的Branches分支以及Merge 应用举例

    come from: http://www.360doc.com/content/12/0816/19/1317564_230547958.shtml 创建Branch分支或者Tag标签 当按照推荐的 ...

  2. JQuery validate 在IE兼容模式下出现 js错误(成员找不到)的修正:

    JQuery validate 在IE兼容模式下 下出现 js错误(成员找不到)的修正: // Add novalidate tag if HTML5. //this.attr( "nova ...

  3. CF109 C. Lucky Tree 并查集

    Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal re ...

  4. mysql事务与mysql储存引擎

    事务概念及存储引擎 1.0 为何要事务? 先来看一个场景,银行转账汇款: 李彦宏和周鸿祎天天打架,现在让李彦宏给周鸿祎转款1000 元 设计如下表 account表 编号(id)用户名(user)金额 ...

  5. [Java] java中的异常处理

    Java中的异常类都继承自Throwable类.一个Throwable类的对象都可以抛出(throw). Throwable对象可以分为两组.一组是unchecked异常,异常处理机制往往不用于这组异 ...

  6. 九度OJ1084

    这道题一旦想开,其实思想十分简单的. 首先考虑n为奇数的情况,不难知f(n)=f(n-1).(只需要把n的所有拆分式-1即可……) 然后考虑n为偶数的情况,将拆分式划分为两种情况:一种是式子中带1的, ...

  7. C Primer Plus(第五版)11

    第 11 章 字符串和字符串函数 在本章中你将学习下列内容: · 函数: gets(), puts(), strcat(), strncat(), strcmp(), strncmp(), strcp ...

  8. (easy)LeetCode 231.Power of Two

    Given an integer, write a function to determine if it is a power of two. Credits:Special thanks to @ ...

  9. linux内核调试指南

    linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级调试 ***第一部分:基础知识*** 总纲:内核世界的陷阱 源码阅读的陷阱 代码调试的陷阱 原理理解的陷阱 ...

  10. Spark是一种分布式的计算方案

    Spark的安装基于HDFS,所以我们要设置hadoop的配置文件,所以spark的存储不是其主要的功能点,而spark作为分布式生态中的角色是一种计算模式(其他 的计算 模式,比如MR,Storm, ...