当前位置:网站首页>asp. Net datatable and some notes of table
asp. Net datatable and some notes of table
2022-06-09 19:57:00 【Bailu-】
DataTable
DataTable table2 = new DataTable();
// Add a row
table2.Columns.Add(" full name ", typeof(string));
// Add a new line
DataRow dr = table2.NewRow();
// Set the contents of the first column of the new row
dr[0] = " Chinese achievement ";
// Add a new line
DataRow dr2 = table2.NewRow();
// Set the contents of the first column of the new row
dr2[0] = " Math scores ";
// I think data inversion is used here , Swap ranks // You can view the previous article :DataTable Exchange of ranks
for (int i = 0; i < table.Rows.Count; i++)
{
// title
table2.Columns.Add(table.Rows[i]["name"].ToString(), typeof(string));
// Here you get the string , For other displays
/*title += "'"+table.Rows[i]["name"].ToString()+"'"; yw+= table.Rows[i]["yw"].ToString(); sx+= table.Rows[i]["sx"].ToString(); if (i != table.Rows.Count - 1) { title += ","; yw+= ","; sx+= ","; } */
// Chinese achievement
dr[table.Rows[i]["name"].ToString()] = table.Rows[i]["yw"].ToString();
// Math scores
dr2[table.Rows[i]["name"].ToString()] = table.Rows[i]["sx"].ToString();
}
// Add two rows of data
table2.Rows.Add(dr);
table2.Rows.Add(dr2);
// Front end control binding data
dateView.DataSource = table2;
// The binding event
dateView.DataBind();
Table
// Add a row
TableRow th = new TableRow();
// Add a blank column , title , That is to say Table Inside TH
th.Cells.Add(new TableHeaderCell());
// Content , That is to say Table Inside TD
TableRow tlr = new TableRow();
TableCell cel=new TableCell();
cel.Text = " Chinese achievement ";
tlr.Cells.Add(cel);
// Content , That is to say Table Inside TD
TableRow tlr2 = new TableRow();
TableCell cel2 = new TableCell();
cel2.Text = " Math scores ";
tlr2.Cells.Add(cel2);
for (int i = 0; i < table.Rows.Count; i++)
{
// title , That is to say Table Inside TH
TableHeaderCell cellth = new TableHeaderCell();
cellth.Text = table.Rows[i]["name"].ToString();
// Add this column to the row
th.Cells.Add(cellth);
//wip
TableCell cell = new TableCell();
// You can add hyperlinks
cell.Text = "<a href='yw.aspx" + "?name=" + table.Rows[i]["name"].ToString() + "&sort='>" + table.Rows[i]["yw"].ToString() + "</a>";
// Add this column to the row
tlr.Cells.Add(cell);
//out
TableCell cell2 = new TableCell();
cell2.Text = "<a href='sx.aspx" + "?name=" + table.Rows[i]["name"].ToString() + "&sort='>" + table.Rows[i]["sx"].ToString() + "</a>";
// Add this column to the row
tlr2.Cells.Add(cell2);
}
// take 3 Line add table
Table1.Rows.Add(th);
Table1.Rows.Add(tlr);
Table1.Rows.Add(tlr2);
Add tools
protected WebControl ToolTabCell(String name,Boolean bln)
{
/* Parameters : Pass in table The content of , Can be hyperlinks Whether it is a content area , Input false Title (th) */
if (bln)
{
TableCell cell = new TableCell();
cell.Text = name;
return cell;
}
else
{
TableHeaderCell cell = new TableHeaderCell();
cell.Text = name;
return cell;
}
}
// Use
// Create a line
TableRow tlr3 = new TableRow();
// Set the background color of this row
tlr3.BackColor = System.Drawing.Color.FromName("#F0FFF0");
// Add a column (td)
tlr3.Cells.Add((TableCell)ToolTabCell(" achievement ", true));
边栏推荐
- 2018年全国职业院校技能大赛中职组“网络空间安全”正式赛卷及评分标准
- Use the code migration tool to migrate the source code to Kunpeng processor
- 普通三进制逻辑数学世界先驱者——伍耀晖先生面向全球公布普通三进制逻辑数学全部真值表科研成果(伍氏定律)
- ASP Err. Detailed description of number error
- C语言实现电脑自动关机程序--可以用来恶搞舍友电脑
- 5 longest palindrome substring (interval DP)
- 5 sous - chaîne palindrome la plus longue (intervalle DP)
- MySQL 8.0.27 installation and configuration tutorial under Windows
- odoo 通过ir.model.access.csv修改其它模块权限
- Not only Lenovo, which sells computers, but also what's new?
猜你喜欢

paramiko和线程池Demo(快速批量操作服务器)

Leetcode stack and queue

范伟OA8前台SQL注入

学习WMX3,运动控制

使用nvm下载安装Node

Alibaba cloud 22q1 status summary, where are you going

软件测试是做什么的?具体工作内容?

The best time to plant a tree is ten years ago, and the second is now (C language selection and cycle training topic)

Betting on cloud nativity, ampere computing starts the key shot of server chip transformation

MySQL data type
随机推荐
MySQL has no service and the ultimate solution sharing that the service cannot be started
Tips for writing code
整形有序数组查找--遍历法与折半法/二分法
中职网络安全 系统漏洞 隐藏信息探索 解析
2022年全国最新消防设施操作员(高级消防设施操作员)考试题库及答案
普通三进制逻辑数学世界先驱者——伍耀晖先生面向全球公布普通三进制逻辑数学全部真值表科研成果(伍氏定律)
Leetcode stack and queue
【UE5】UObject中调用WorldSubsystem
C语言实现猜数字游戏
Exploration and analysis of hidden information of network security system vulnerabilities in Secondary Vocational Schools
马斯克怎么成了币圈靳东?
Learn wmx3, motion control
Taiwan once again strictly investigated the poaching of mainland enterprises: more than 100 people were dispatched, 10 enterprises were investigated, and nearly 70 people were interviewed!
Xcode 14 带来全新提升,Xcode Cloud 正式推出!
How to generate a QR code picture (add a Chinese logo) and save it to the specified picture static service address, so as to solve the problem that there are no QR code Chinese characters.
How to view Tekton's pipeline indicators
[resource sharing] comprehensive navigation website
【tgowt】cmake转ninja构建
NoSQL之Redis配置与优化(你不在南京的日子我替你吹了秦淮河的晚风)
MySQL optimization tutorial: slow query log practice