dev初识 拖动分组
1.前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication15.WebForm1" %>
<%@ Register Assembly="DevExpress.Web.v15.1, Version=15.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False">
<SettingsPager PageSize="30" Position="TopAndBottom" SEOFriendly="Enabled" >
</SettingsPager>
<Settings ShowGroupPanel="True" ShowGroupFooter="VisibleAlways"></Settings>
<SettingsBehavior AllowFixedGroups="False" AllowGroup="True" AllowDragDrop="True"/>
<Columns>
<dx:GridViewDataTextColumn FieldName="No" UnboundType="Integer" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Name" UnboundType="String" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
<GroupSummary>
<dx:ASPxSummaryItem DisplayFormat="合计:0" FieldName="Name" SummaryType="Sum" />
</GroupSummary>
</dx:ASPxGridView>
</div>
</form>
</body>
</html>
2.后台代码
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication15
{
public class Student
{
public int No { get; set; }
public int Name { get; set; }
}
public static class ListAndTableExt
{
public static DataTable ToDataTable<T>(this List<T> list) where T : class, new()
{
DataColumn column = null;
DataTable table = new DataTable();
List<PropertyInfo> ps = typeof(T).GetProperties().ToList();
ps.ForEach(p =>
{
if (!p.PropertyType.IsGenericType)
{
column = new DataColumn(p.Name, p.PropertyType);
}
else
{
if (p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
column = new DataColumn(p.Name, Nullable.GetUnderlyingType(p.PropertyType));
}
}
if (column != null)
{
table.Columns.Add(column);
}
});
list.ForEach(obj =>
{
DataRow row = table.NewRow();
ps.ForEach(p =>
{
row[p.Name] = p.GetValue(obj, null);
});
table.Rows.Add(row);
});
return table;
}
public static List<T> ToList<T>(this DataTable table) where T : class, new()
{
List<PropertyInfo> ps = typeof(T).GetProperties().ToList();
List<T> list = new List<T>();
foreach (DataRow row in table.Rows)
{
T obj = new T();
foreach (DataColumn col in table.Columns)
{
ps.ForEach(p =>
{
if (p.Name == col.ColumnName)
{
if (!p.PropertyType.IsGenericType)
{
p.SetValue(obj, string.IsNullOrEmpty(row[p.Name].ToString()) ? null : Convert.ChangeType(row[p.Name].ToString(), p.PropertyType));
}
else
{
if (p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
p.SetValue(obj, string.IsNullOrEmpty(row[p.Name].ToString()) ? null : Convert.ChangeType(row[p.Name], Nullable.GetUnderlyingType(p.PropertyType)));
}
}
}
});
}
list.Add(obj);
}
return list;
}
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Student> stuList = new List<Student>();
for (int i = 0; i < 100; i++)
{
stuList.Add(new Student() { No = i, Name = i });
}
stuList.Add(new Student() { No = 1, Name = 22 });
stuList.Add(new Student() { No = 1, Name = 33 });
DataTable table = stuList.ToDataTable();
ASPxGridView1.DataSource = table;
ASPxGridView1.DataBind();
List<Student> students = table.ToList<Student>();
}
}
}
dev初识 拖动分组的更多相关文章
- dev gridview 设置分组
private void GridConfig() { GridGroupSummaryItem item = new GridGroupSummaryItem(); item.FieldName = ...
- 手把手教从零开始在GitHub上使用Hexo搭建博客教程(三)-使用Travis自动部署Hexo(1)
前言 前面两篇文章介绍了在github上使用hexo搭建博客的基本环境和hexo相关参数设置等. 基于目前,博客基本上是可以完美运行了. 但是,有一点是不太好,就是源码同步问题,如果在不同的电脑上写文 ...
- 跟我一起学extjs5(19--模块记录的拖放删除、拖放复制新增)
跟我一起学extjs5(19--模块记录的拖放删除.拖放复制新增) 网页其中的拖放(drag-drop)是比較有趣的操作,extjs5中非常好的封装了拖放的动作,也有各种类来支持,可是 ...
- 18、手把手教你Extjs5(十八)模块记录的拖放删除、拖放复制新增
网页当中的拖放(drag-drop)是比较有趣的操作,extjs5中很好的封装了拖放的动作,也有各种类来支持,但是要学好“拖放”这个东西真是很难,特别是象我这样英语不好的人,看不太懂官网上的说明,做一 ...
- C#实现DevExpress本地化实例详解
using System; using System.Collections.Generic; using System.Text; using DevExpress.XtraGrid.Localiz ...
- ArchLinux安装步骤(一)
本文为安装archlinux的教程,需要有硬盘分区,挂载等基础linux命令的了解还有vim的基本操作,不知道也没关系,这里有大神的视频教程ArchLinux指南. 确实是不是uefi模式 ls /s ...
- 18-Spring Cloud Alibaba Nacos
简介 为什么叫Nacos 前四个字母分别为Naming和Configuration的前两个字母,最后的s为Service Nacos是什么 一个更易于构建云原生应用的动态服务发现.配置管理和服务管理平 ...
- 耗时半年,Eoapi 终于正式发布 API 工具的插件广场
这是我们的第一篇月报,每个月和每个来之不易的开发者分享产品故事以及产品进展. 在 5.20 这个极具中国特色的"节日"里,Eoapi 发布了 1.0.0 版,三个程序员掉了半年 ...
- Dev用于界面按选中列进行分组统计数据源(实用技巧)
如果有用U8的可以明白这个功能就是模仿他的统计功能.我不过是把他造成通用的与适应于DEV的. (效率为6000条数据分组统计时间为3秒左右分组列过多5秒.1000条以下0.几秒,500条下0.00几秒 ...
随机推荐
- 【spring源码学习】spring的远程调用实现源码分析
[一]spring的远程调用提供的基础类 (1)org.springframework.remoting.support.RemotingSupport ===>spring提供实现的远程调用客 ...
- Spring IOC容器在Web容器中是怎样启动的
前言 我们一般都知道怎样使用spring来开发web应用后,但对spring的内部实现机制通常不是很明白.这里从源码角度分析下Spring是怎样启动的.在讲spring启动之前,我们先来看看一个web ...
- Windows Communication Foundation (WCF)和Windows CardSpace的示例程序
微软公司昨天发布了一个Windows Communication Foundation (WCF)和Windows CardSpace的示例程序包,内容极为丰富,从最简单的Hello World到复杂 ...
- weblogic控制台的启动与禁用
在一些安全漏洞扫描中,经常会扫描发现,使用weblogic管理控制台,会有个中危的漏洞. http://192.168.10.46:7001/console/login/LoginForm.jsp W ...
- php通过存储过程传入汉字参数并写入数据库
写入数据库,汉字为???样式的乱码,后根据网上介绍的方法,参数前加N,数据库汉字内容变成空白. 解决方法,在PHP中先转为base64,再在mysql中base64解码,前提先保证mysql中有bas ...
- 一键获取 所有连接过的WIFI密码
使用方法 一.运行CMD (以及 开启无线网卡.最好是笔记本) 二.输入命令: for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh ...
- php对数组中的值进行排序
案例 <?php $a = array('1124','1125','1126'); $s1 = 1124; $s2 = 1125; $ks1 = array_search($s1,$a); $ ...
- mysql 内存体系结构--session
体系结构tmp_table_size & max_heap_table_size ,这个是会话级的内存结构mysql使用总内存 = global_buffers + thread_buffer ...
- Sql server 2008 R2 正在关闭[0x80041033]
1. 事件起因, 昨天还访问的好好的, 然后系统一更新, 今天访问的时候, 就报什么 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是 ...
- Cocos暂停和重新开始游戏
创建按钮 cc.MenuItemFont.setFontSize(18); cc.MenuItemFont.setFontName("Arial"); var systemMenu ...