Introduction to dynamic Table Generation and attributes of server control table in ASP. NET

Source: Internet
Author: User

The server control table in ASP. NET dynamically generates a table

 

Table TB = new table ();

Int ROW = 3; // number of rows
Int Col = 4; // Number of Columns
For (INT I = 0; I <row; I ++)

{
Tablerow TR = new tablerow ();
TB. Rows. Add (TR );

For (Int J = 0; j <Col; j ++)

{
Tablecell TD = new tablecell ();
Tr. cells. Add (TD );
TD. Text = I. tostring ();
}
}

This article is transferred from:Http://zhidao.baidu.com/question/90916310.html

 

========================================================== ==================

Asp.net Table Control

Function: create a universal table on the web page.

Attribute:

1. cellpadding attribute: used to set the distance (in pixels) between the border and content of cells in the table ). The default value is-1 (not set ).

2. cellspacing attribute: used to set the distance between cells in a table (in pixels ). The default value is-1 (not set ).

3. Rows attribute: used to obtain the set of table rows. The main attributes and methods are as follows:

● Count attribute: number of elements in the rows set (that is, the number of rows in the table );

● Add method: Used to add a new tablerow object (that is, adding a row to the table );

● Addat method: Used to add a new tablerow object (insert a row to the table) at the specified position );

● Remove Method: used to remove a tablerow object (that is, remove a row from the table );

● Removeat method: used to remove the tablerow object of the specified index value (that is, to remove the row of the specified index value from the table );

● Clear method: Clear all elements in the rows set (that is, clear all rows in the table ). Row (I) is used to indicate the I-th element in the rows set (counted from 0)

4. gridlines attribute: used to specify the grid style displayed in the table control. Possible style values include:

● None: the cell border is not displayed;

● Horizontal: displays only the horizontal boxes of cells;

● Vertical: only the vertical border of a cell is displayed;

● Both: horizontal border and vertical border are displayed at the same time.

5. horizontalalign attributes:

Sets the horizontal alignment of the table content. Possible Alignment Methods are as follows:

Center: center;

Left: Left alignment;

Noset: not set;

Right: Right-aligned;

Justify: The table content can be expanded and aligned with the left and right margins.

Main attributes of the tablelrow object:

1. Cells attribute: indicates the set of cells in the table row. The main attributes and methods of the Cell set are as follows:

Count attribute: number of elements in the cells set (that is, number of columns );

Add method: Used to add a new tablecell object (that is, to add a cell to the table );

Addat: Used to add a new tablecell object (insert a cell to the table row) at the specified position );

Remove Method: Remove a tablecell object (that is, remove a cell from the table row );

Removeat method: used to remove the tablecell object with the specified index value (that is, remove the cell with the specified index value from the table row );

Clear: Clear all elements in the cells set (that is, clear all cells in the table row );

Cells (j) can be used to represent the J-th element in the cells set (counted from 0 ).

2. horizontalalign attributes:

Sets the horizontal alignment of row content. Possible alignment values are the same as the horizontalalign attribute values of the table control.

3. verticalalign attribute: used to specify the vertical alignment of row content. Possible alignment values include:

Notset: no alignment is set;

Top: the row content is aligned with the top edge of the row;

Middle: Align the vertical direction of the row content;

Bottom: the content of the row is aligned with the bottom edge of the row.

Main Properties of tablecell alignment

1. columnspan attribute: the number of columns that the cell spans in the displayed table. For example, if the attribute value of columnspan is 2, the cell occupies two columns in the table control.

2. horizontalalign attribute: used to set the horizontal alignment of column content. Its attribute value and meaning are the same as those of the horizaontalalign attribute of the table control.

3. rowspan attribute: indicates the number of rows that the cell spans in the displayed table. For example, if the rowspan attribute value is 2, the cell occupies two rows in the table control.

4. verticalalign attribute: used to specify the vertical alignment of the column content. Its attribute value and meaning are similar to those of the horizontalalign attribute of the tablerow object. The difference is that the content of the specified column is vertical align.

5. Wrap attribute: the attribute value determines whether to allow text wrapping in cells. If line breaks are allowed, the attribute value is true. Otherwise, the value is false.

 

This article is from the csdn blog, Reprint please indicate the source: http://blog.csdn.net/yandong19861103/archive/2009/02/24/3932651.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.