The Table control Web Controls

260 Dim oList As ListItem For Each oList In oListBox.Items If oList.Selected Then Do something End If Next

6.3.1.7 The RadioButton control

The RadioButton control corresponds to a single button in a group of buttons used to indicate mutually exclusive choices. It has the following HTML syntax: asp:RadioButton id=RadioButtonName AutoPostBack=True|False Checked=True|False GroupName=GroupName Text=label TextAlign=Right|Left OnCheckedChanged=OnCheckedChangedMethod runat=server As in the CheckBox control, the Checked attribute determines whether the control is checked. Only one control in the group designated by GroupName can be set to True . The default value of the Checked attribute is False . However, since it is possible for the Checked attributes of all radio buttons in a group to be False , it is important to initially set the Checked attribute of one member of the group to True . The GroupName attribute provides a common name by which all radio buttons in the group can be identified. The Text attribute defines the caption that appears either to the left the default or to the right of the radio button, depending on the setting of the TextAlign attribute. Each of these attributes of the RadioButton control directly corresponds to an identically named property of the System.Web.UI.WebControls.RadioButton class. The value of the TextAlign property is either of the two members of the TextAlign enumeration: TextAlign.Left , which positions the text to the left of the checkbox the default; and TextAlign.Right , which positions the text to the right of the checkbox. The Checked property is a Boolean that can be programmatically set and can also change as a result of user interaction. Note that the user changing the Checked property of another radio button in the group from False to True automatically changes the value of the Checked property of any checked radio button from True to False . Finally, the OnCheckedChanged attribute defines an event handler that will be executed whenever the Checked property of the radio button is changed. The event handler designated by the OnCheckedChanged attribute must have the following signature: Sub OnCheckedChangedMethodsender As Object, e As EventArgs

6.3.1.8 The Table control

The Table control corresponds to a table consisting of multiple rows, each having one or more columns. A table need not be symmetrical—that is, it need not have the same number of columns in each row. The Table control has the following HTML syntax: asp:Table id=TableName BackImageUrl=url CellSpacing=cellspacing CellPadding=cellpadding GridLines=None|Horizontal|Vertical|Both HorizontalAlign=Center|Justify|Left|NotSet|Right runat=server 261 asp:TableRow asp:TableCell Cell text asp:TableCell asp:TableRow asp:Table The TableRow tag defines a new table row, while the TableCell tag defines a new cell within a particular row. The contents of the individual cell are defined by Cell text . The HorizontalAlign attribute determines the horizontal alignment of the table on the page. The GridLines attribute determines the appearance of grid lines in the table. The CellSpacing attribute determines the number of pixels that separate individual cells of the table, while the CellPadding attribute determines the number of pixels between the cells border and its contents. The BackImageURL attribute contains the URL of an image to be used as the background for the table. Each of these attributes corresponds to an identically named property of the Table class. The CellPadding and CellSpacing properties are of type Integer. The value of the HorizontalAlign property is one of the following members of the HorizontalAlign enumeration: Center , Justify , Left , NotSet , and Right . The value of the GridLines property is one of the following members of the GridLines enumeration: Both , Horizontal , None , and Vertical . You programmatically manipulate a table by manipulating its rows and its individual cells. The table rows are accessible through the Table objects Rows property, which returns a TableRowCollection object containing TableRow objects that represent the rows of the table. The TableRowCollection collection allows you to add rows to the end of the table by calling its Add method, which has the following syntax: TableRowCollection.Add row where row is a TableRow object that represents a row of the table. To add a row to a particular place in the table, you can call the Insert method, which has the following syntax: TableRowCollection.Insertindex, row where index is the zero-based position in the table at which the row is to be added and row is a RowTable object representing the row to be added to the table. You can also remove rows from the table by calling the TableRowCollection objects Remove and RemoveAt methods. The syntax of the Remove method is: TableRowCollection.Removerow where row is a TableRow object representing the row to be deleted. The syntax of the RemoveAt method is: TableRowCollection.RemoveAtindex where index is the position of the row to be removed from the table. The number of items in the table is provided by the TableRowCollection objects Count property. Individual TableRow objects representing individual rows of the table can be retrieved using the Item property, whose syntax is: TableRowCollection.Itemindex 262 where index is the zero-based ordinal position of the row whose TableRow object you wish to retrieve. Once youve retrieved a reference to an individual table row, you can use its Cells property to retrieve a reference to a TableCellCollection object, which contains a collection of TableCell objects representing the individual cells of the row. Like the TableRowCollection class, the TableCellCollection class has members to add and remove individual cells as well as to determine how many cells are in the collection. Its syntax for adding and removing cells is identical to that of the TableRowCollection class, except that TableCell objects are used instead of TableRow objects. Finally, to retrieve an individual cell, you use the TableCellCollection objects Item method, which has the following syntax: TableCellCollection.Itemindex where index is the zero-based ordinal position of the cell in the row. The property returns a TableCell object representing the cell. Finally, the TableCell class has a number of properties that control the content and appearance of the cell. The Text property determines the cells content. The Boolean Wrap property determines whether the contents of the cell wrap in the cell; its default value is True . The RowSpan and ColumnSpan properties are Integer values that indicate how many table rows and how many table columns the cell spans. The HorizontalAlign property, whose value is a member of the HorizontalAlign enumeration discussed earlier in this section, determines the horizontal alignment of the cells contents. The VerticalAlign property determines the vertical alignment of the cells contents. Its value must be a member of the VerticalAlign enumeration, which has the following members: Bottom , Middle , NotSet , and Top .

6.3.1.9 The TextBox control