System.Web.UI.WebControls Namespace BaseDataList Class
Sets or retrieves a value that specifies whether the border between the cells of a data listing control is displayed.
Inline |
<asp:basedatalist gridlines = enumValue ... > |
Script |
BaseDataList.GridLines [ = enumValue ] |
The property is read/write with a default value of Both.
Use the GridLines property to specify whether the border between the cells of a data listing control is displayed. This property is set with one of the GridLines enumeration values.
The sample below shows how to programmatically set the GridLines property of a DataGrid at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system grid styles and dynamically add each to a selectable list.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ICollection grids =
TypeDescriptor.GetConverter ( typeof ( GridLines ) ).GetStandardValues ( );
foreach ( GridLines g in grids ) {
GridSelect.Items.Add ( g.ToString ( ) );
}
GridSelect.SelectedIndex = 2;
string query = "SELECT ... FROM Employees";
myGrid.DataSource = fetchData ( query, "northwind" );
myGrid.DataBind ( );
}
myGrid.GridLines = ( GridLines ) GridSelect.SelectedIndex;
}
Sub Page_Load ( src As Object, e As EventArgs )
If Not IsPostBack Then
Dim grids As ICollection = _
TypeDescriptor.GetConverter ( GetType ( GridLines ) ).GetStandardValues ( )
Dim g As GridLines
For Each g In grids
GridSelect.Items.Add ( g.ToString ( ) )
Next g
GridSelect.SelectedIndex = 2
Dim query As String = "SELECT ... FROM Employees"
myGrid.DataSource = fetchData ( query, "northwind" )
myGrid.DataBind ( )
End If
myGrid.GridLines = CType ( GridSelect.SelectedIndex, GridLines )
End Sub |
|
C# |
VB |
Show me
BaseDataList Members CellPadding CellSpacing