当前位置:网站首页>ASP dynamically creates table table
ASP dynamically creates table table
2022-06-29 21:58:00 【Eighty eight old】
newly build web forms Table
add to Table Control 
Set up Table attribute ( towards Table Object add row use Rows attribute , towards TableRow Object to add cells using Cells attribute )

stay aspx.cs Add the following code to realize dynamic creation
protected void Page_Load(object sender, EventArgs e)
{
string[] name = {
" Younger sister "," brother "};
string[] number = {
"201924111", "201924112" };
for (int i= 1; i<=2; i++)
{
TableRow row = new TableRow();// Create a row object
TableCell cellNumber = new TableCell(); // Create the first cell object
TableCell cellName = new TableCell();
TableCell cellInput = new TableCell();
cellNumber.Text = number[i - 1];
cellName.Text = name[i - 1];
TextBox txtInput = new TextBox();// Create a text box object
cellInput.Controls.Add(txtInput);// Add a text box object to the third cell
row.Cells.Add(cellNumber);// Add the first cell to the row object
row.Cells.Add(cellName);
row.Cells.Add(cellInput);
tblScore.Rows.Add(row);// Add row objects to table objects
}
}
aspx Complete code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table.aspx.cs" Inherits="Chap2_Table" %>
<!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>
<asp:Table ID="tblScore" runat="server">
<asp:TableRow runat="server">
<asp:TableCell runat="server"> Student number </asp:TableCell>
<asp:TableCell runat="server"> full name </asp:TableCell>
<asp:TableCell runat="server"> achievement </asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
aspx.cs Complete code
using System;
using System.Web.UI.WebControls;
public partial class Chap2_Table : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string[] name = {
" Younger sister "," brother "};
string[] number = {
"201924111", "201924112" };
for (int i= 1; i<=2; i++)
{
TableRow row = new TableRow();// Create a row object
TableCell cellNumber = new TableCell(); // Create the first cell object
TableCell cellName = new TableCell();
TableCell cellInput = new TableCell();
cellNumber.Text = number[i - 1];
cellName.Text = name[i - 1];
TextBox txtInput = new TextBox();// Create a text box object
cellInput.Controls.Add(txtInput);// Add a text box object to the third cell
row.Cells.Add(cellNumber);// Add the first cell to the row object
row.Cells.Add(cellName);
row.Cells.Add(cellInput);
tblScore.Rows.Add(row);// Add row objects to table objects
}
}
}
边栏推荐
- Topic39——78. subset
- Matlab output format control%d,%f,%c,%s usage
- Huawei cloud AOM version 2.0 release
- A. Print a Pedestal (Codeforces logo?)
- A new Polaris has risen!
- jfinal中如何使用过滤器监控Druid监听SQL执行?
- CORDIC based Signal Processor desgn
- Shutter bottomnavigationbar with page switching example
- [fishing artifact] code tool for lowering the seconds of UI Library -- form part (I) design
- C. Most Similar Words
猜你喜欢

什么是 SYN 洪水攻击?如何防护?

PostgreSQL weekly news - June 22
![The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem](/img/96/b1595b9d2b008b353765caa68fdd3c.png)
The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem

After inventing anti-virus software, he chose to be a top-notch gangster

American tunneling ASTM E84 surface flame retardant test

Digital password lock Verilog design + simulation + on board verification

ASP利用Panel实现简易注册页面

Report delivery engineer

Deep learning remote sensing data set

Layer 3 loop brought by route Summary - solution experiment
随机推荐
阿里巴巴关键字搜索商品API接口(item_search-按关键字搜索商品接口),阿里巴巴搜索API接口
[advanced ROS] Lecture 3 ROS file system and distributed communication
PostgreSQL weekly news - June 22
BUAA OO unit 4 HW16 unit 4 Summary and course review
Sophon CE community edition goes online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
What is unique about MES system?
LeetCode 1. Sum of two numbers
Don't worry about form deformation anymore
Information available from radar echo
I want to register my stock account online. How do I do it? In addition, is it safe to open a mobile account?
Datakit acts as an API server for local data acquisition
cout 不明确问题
【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)
CSDN failed to replicate problem
Knowledge distilling learning notes
What is a SYN Flood attack? How to protect?
Go standard library context package: data, cancellation signal, deadline and other related operations between a single request and multiple goroutines and the request domain
Desai wisdom number - other charts (basic sunrise chart): high frequency words in graduation speech
铝板AS/NZS 1530.1 不燃性材料的阻燃测试