| |||||||||||||||||||||||||||||||||||||
DataGrid ClassSystem.Web.UI.WebControls Namespace A data bound list control that displays the records from a data source in a tabular grid.
RemarksUse the DataGrid control to display the fields of a data source as columns in a table. Each row in the DataGrid control represents a record in the data source. The DataGrid control supports selection, editing, deleting, paging, and sorting. Different column types determine the behavior of the columns in the control. The following table lists the different column types that can be used.
By default, the AutoGenerateColumns property is set to true, which creates a BoundColumn object for each field in the data source. Each field is then rendered as a column in the DataGrid control in the order that each field appears in the data source. You can also manually control which columns appear in the DataGrid control by setting the AutoGenerateColumns property to false and then listing the columns that you want to include between the opening and closing <Columns> tags. The columns specified are added to the Columns collection in the order listed. This allows you to programmatically control the columns in the DataGrid control.
The appearance of the DataGrid control may be customized by setting the style properties for the different parts of the control. The following table lists the different style properties.
You can also show or hide different parts of the control. The following table lists the properties that control which parts are shown or hidden.
You can also control the appearance of the DataGrid control by programmatically adding attributes to the <td> and <tr> tags rendered by the control on the browser. Attributes can be programmatically added by providing code in the event handler for the OnItemCreated or OnItemDataBound event. To add an attribute to the <td> tag, first get the TableCell object that represents the cell in the DataGrid control you want to add the attribute to. The Control.Controls collection for the Item property ( DataGridItemEventArgs indexer ) of the DataGridItemEventArgs object passed into the event handler can be used to get the desired TableCell object. You can then use the AttributeCollection.Add method of the Attributes collection for the TableCell object to add attributes to the <td> tag. To add an attribute to the <tr> tag, first get the DataGridItem object that represents the row in the DataGrid control you want to add the attribute to. The Item property ( DataGridItemEventArgs indexer ) of the DataGridItemEventArgs object passed into the event handler can be used to get the desired DataGridItem object. You can then use the AttributeCollection.Add method of the Attributes collection for the DataGridItem object to add attributes to the <tr> tag. See AlsoBaseDataList DataList Repeater BoundColumn ButtonColumn EditCommandColumn HyperLinkColumn TemplateColumn |
| ||||||||||||||||||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note