No 31 · 在web页中使用表格控件

来源:互联网 发布:数据库的开发 编辑:程序博客网 时间:2024/05/18 17:27
#define Hywork using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Text;public partial class _Default : System.Web.UI.Page {    protected void Page_Load(object sender, EventArgs e)    {        AddRow("姓名", "专业", "所在学校", "个人网站");        AddRow("小明", "计算机系", "吉林大学", "http://www.mingrisoft.com");        AddRow("小强", "计算机系", "吉林大学", "http://www.mingrisoft.com");        AddRow("小刘", "计算机系", "吉林大学", "http://www.mingrisoft.com");        AddRow("小张", "计算机系", "吉林大学", "http://www.mingrisoft.com");        AddRow("小陈", "计算机系", "吉林大学", "http://www.mingrisoft.com");      }    public void AddRow(string strName1, string strName2, string strName3, string strName4)    {         TableRow row = new TableRow();        //第一行第1列        TableCell cell1 = new TableCell();        cell1.Font.Size = FontUnit.XXSmall;        cell1.Text = strName1;        cell1.Width = 80;        row.Cells.Add(cell1);        //第一行第2列        TableCell cell2 = new TableCell();        cell2.Font.Size = FontUnit.XXSmall;        cell2.Text = strName2;        cell2.Width = 80;        row.Cells.Add(cell2);        //第一行第3列        TableCell cell3 = new TableCell();        cell3.Font.Size = FontUnit.XXSmall;        cell3.Text = strName3;        cell3.Width = 80;        row.Cells.Add(cell3);        //第一行第4列        HyperLink hyperLink = new HyperLink();        hyperLink.Text = strName4;        hyperLink.NavigateUrl = strName4;        hyperLink.Target = "_top";        TableCell cell4 = new TableCell();        cell4.Font.Size = FontUnit.XXSmall;        cell4.Controls.Add(hyperLink);        cell4.Width = 240;        row.Cells.Add(cell4);        this.Table1.Rows.Add(row);    }}

原创粉丝点击