Web Server Controls->ASP.NET TableCell Control
2007-03-27 16:11
651 查看
Definition and Usage
The TableCell control is used in conjunction with the Table control and the TableRow control to create a cell in a table.Tip: The cells of each row are stored in the Cells collection of the TableRow control.
Properties
Property | Description |
---|---|
ColumnSpan | The number of columns this cell should span |
HorizontalAlign | The horizontal alignment of the contents in the table cell. Legal values are: Center Justify Left NotSet Right |
id | A unique id for the control |
RowSpan | The number of rows this cell should span |
runat | Specifies that the control is a server control. Must be set to "server" |
VerticalAlign | The vertical alignment of the contents in the table cell. Legal values are: Bottom Middle NotSet Top |
Wrap | A Boolean value that indicates whether the cell's contents should wrap or not |
Examples
TableASPX Source:
<html> <body> <form runat=server> <asp:Table runat="server" CellPadding="5" GridLines="horizontal" HorizontalAlign="Center"> <asp:TableRow> <asp:TableCell>1</asp:TableCell> <asp:TableCell>2</asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell>3</asp:TableCell> <asp:TableCell>4</asp:TableCell> </asp:TableRow> </asp:Table> <br /> <asp:Table runat="server" CellPadding="5" GridLines="vertical" HorizontalAlign="Center"> <asp:TableRow> <asp:TableCell>1</asp:TableCell> <asp:TableCell>2</asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell>3</asp:TableCell> <asp:TableCell>4</asp:TableCell> </asp:TableRow> </asp:Table> </form> </body> </html> |
Output Result:
|
Table 2
ASPX Source:
<script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) dim rows,cells,j,i rows=3 cells=2 For j=0 To rows-1 dim r As New TableRow() For i=0 To cells-1 dim c As New TableCell() c.Controls.Add(New LiteralControl("row " & j & ", cell " & i)) r.Cells.Add(c) Next Table1.Rows.Add(r) Next End Sub </script> <html> <body> <form runat="server"> <asp:Table id="Table1" BorderWidth="1" GridLines="Both" runat="server" /> </form> </body> </html> |
Output Result:
|
相关文章推荐
- Web Server Controls->ASP.NET TableRow Control
- Web Server Controls->ASP.NET Table Control
- HTML Controls->ASP.NET HtmlTableCell Control
- Web Server Controls->ASP.NET ImageButton Control
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET RadioButton Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET RadioButtonList Control
- Web Server Controls->ASP.NET XML Control
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET AdRotator Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- Web Server Controls->ASP.NET HyperLink Control
- Web server Controls->ASP.NET TextBox Control
- Web Server Controls->ASP.NET Button Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Image Control
- Web Server Controls->ASP.NET PlaceHolder Control