代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
GridView转化为DataTable
作者:
Dezai.CN
/ 发布于
2012/6/21
/
601
GridView转化为DataTable
<div> /**/ /// <summary> /// 从GridView的数据生成DataTable /// </summary> /// <param name="gv">GridView对象</param> public static DataTable GridView2DataTable(GridView gv) { DataTable table = new DataTable(); int rowIndex = 0; List<string> cols = new List<string>(); if (!gv.ShowHeader && gv.Columns.Count == 0) { return table; } GridViewRow headerRow = gv.HeaderRow; int columnCount = headerRow.Cells.Count; for (int i = 0; i < columnCount; i++) { string text = GetCellText(headerRow.Cells[i]); cols.Add(text); } foreach (GridViewRow r in gv.Rows) { if (r.RowType == DataControlRowType.DataRow) { DataRow row = table.NewRow(); int j = 0; for (int i = 0; i < columnCount; i++) { string text = GetCellText(r.Cells[i]); if (!String.IsNullOrEmpty(text)) { if (rowIndex == 0) { string columnName = cols[i]; if (String.IsNullOrEmpty(columnName)) { continue; } if (table.Columns.Contains(columnName)) { continue; } DataColumn dc = table.Columns.Add(); dc.ColumnName = columnName; dc.DataType = typeof(string); } row[j] = text; j++; } } rowIndex++; table.Rows.Add(row); } } return table; } public static string GetCellText(TableCell cell) { string text = cell.Text; if (!string.IsNullOrEmpty(text)) { return text; } foreach (Control control in cell.Controls) { if (control != null && control is IButtonControl) { IButtonControl btn = control as IButtonControl; text = btn.Text.Replace("\r\n", "").Trim(); break; } if (control != null && control is ITextControl) { LiteralControl lc = control as LiteralControl; if (lc != null) { continue; } ITextControl l = control as ITextControl; text = l.Text.Replace("\r\n", "").Trim(); break; } } return text; } </div>
试试其它关键字
GridView转化为DataTable
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
实现测量程序运行时间及cpu使用时间
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3