DbNetList Server Reference

Top  Previous  Next

Properties

The simplest instance of DbNetList can be created by specifying just the ConnectionString and Sql properties

ConnectionString

The ConnectionString property provides the information necessary to connect to the database. The connection string can either be an actual connection string or an alias which is resolved by finding a matching entry in the <connectionStrings> section of the web.config file. For details of specifying connection strings see the database connectivity section.

HeaderRow

Controls the display of a heading row for the list. The default is false.

ListClientEvents

The ListClientEvents collection allows you to specify handlers for any of the client-side events that are available.

<DNL:DbNetList 
	id="DbNetList1" 
	runat="server" 
	ConnectionString = "SamplesDatabase"
	Sql = "select categoryname, categoryid from categories order by 1"
	>
	<ListColumns>
		<DNL:ListColumn ColumnExpression="categoryid" Display="false"/>
	</ListColumns>
	<NestedList
		id="DbNetList2" 
		runat="server" 
		Sql = "select productname, discontinued, productid from products where categoryid = ? order by 1">
		<Parameters>
			<DNL:Parameter Name="categoryid" Value=""/>
		</Parameters>
		<ListClientEvents>
			<DNL:ListClientEvent EventName="onRowTransform" Handler="transformRow"/>
			<DNL:ListClientEvent EventName="onLinkSelected" Handler="showSelectedProduct"/>
		</ListClientEvents>
		<ListColumns>
			<DNL:ListColumn ColumnExpression="productname" Selectable="true"/>
			<DNL:ListColumn ColumnExpression="discontinued" Display="false"/>
			<DNL:ListColumn ColumnExpression="productid" Display="false"/>
		</ListColumns>
	</NestedList>
</DNL:DbNetList>				

Run Sample

ListColumns

Collection of ListColumn objects that supplies column properties

<DNL:DbNetList 
	id="DbNetList1" 
	runat="server" 
	ConnectionString = "SamplesDatabase"
	Sql = "select LastName, FirstName, BirthDate, HireDate from employees order by 1"
	HeaderRow = "true"
	RowSelection = "true"
	Style="border:1pt solid silver"
	>
	<ListColumns>
		<DNL:ListColumn ColumnExpression="BirthDate" Format="D"/>
		<DNL:ListColumn ColumnExpression="HireDate" Format="MMMM yyyy"/>
	</ListColumns>
</DNL:DbNetList>		

 

NestedList

The NestedList property can be used to define an instance of a linked child list that is displayed as a child node of a multi-tier tree-style list. The relationship between the parent and child grid is created by specifying empty Parameter values with  names that correspond with the columns containing the parameter values in the parent list.

<DNL:DbNetList 
	id="DbNetList1" 
	runat="server" 
	ConnectionString = "SamplesDatabaseVistaDB"
	Sql = "select distinct country from customers where country is not null order by 1"
	>
	<NestedList
		id="DbNetList2" 
		runat="server" 
		Sql = "select distinct city from customers where country = @country order by 1">
		<Parameters>
			<DNL:Parameter Name="country" Value=""/>
		</Parameters>
		<NestedList
			id="DbNetList3" 
			runat="server" 
			Sql = "select companyname, customerid from customers where city = @city order by 1">
			<Parameters>
				<DNL:Parameter Name="city" Value=""/>
			</Parameters>
			<ListColumns>
				<DNL:ListColumn ColumnExpression="customerid" Display="false"/>
			</ListColumns>
			<NestedList
				id="DbNetList4" 
				runat="server" 
				Sql = "select orderdate, orderid from orders where customerid = @customerid order by 1">
				<Parameters>
					<DNL:Parameter Name="customerid" Value=""/>
				</Parameters>
				<ListColumns>
					<DNL:ListColumn ColumnExpression="orderdate" Format="D"/>
					<DNL:ListColumn ColumnExpression="orderid" Display="false"/>
				</ListColumns>
				<NestedList
					id="DbNetList5" 
					runat="server" 
					Sql = "select productname, quantity from [order details] join products on products.productid = [order details].productid where orderid = @orderid"
					HeaderRow="true"
					>
					<Parameters>
						<DNL:Parameter Name="orderid" Value=""/>
					</Parameters>
					<ListColumns>
						<DNL:ListColumn ColumnExpression="productname" Label="Product Name"/>
						<DNL:ListColumn ColumnExpression="quantity" Label="Qty"/>
					</ListColumns>
				</NestedList>
			</NestedList>
		</NestedList>
	</NestedList>
</DNL:DbNetList>	

Run Sample

Parameters

Collection of Parameter objects that supplies parameter values for any parameter placeholders in the Sql statement

<DNL:DbNetList 
	id="DbNetList1" 
	runat="server" 
	ConnectionString = "SamplesDatabase"
	Sql = "select * from customers where country = ?"
	HeaderRow = "true"
	>
	<Parameters>
		<DNL:Parameter Name="Country" Value="USA"/>
	</Parameters>
</DNL:DbNetList>	

RowSelection

In enabled will highlight the selected row.

Sql

Specifies the SQL statement that will be run against the database and used to populate the list of items in the list.

TreeImageUrl (string)

Specifies the URL of a custom image for the tree node in a nested list.

Run Sample

Column Properties

Columns are assigned with the ListColumns collection referencing the column name specified in Sql property.

<DNL:DbNetList 
	id="DbNetList1" 
	runat="server" 
	ConnectionString = "SamplesDatabase"
	Sql = "select CompanyName,ContactName,Address,City,Region,Country,Phone,Fax from customers order by companyname"
	Width = "250px"
	Height = "200px"
	RowSelection = "True"
	>
	<ListClientEvents>
		<DNL:ListClientEvent EventName="onRowSelected" Handler="displayCustomer"/>
	</ListClientEvents>
	<ListColumns>
		<DNL:ListColumn ColumnExpression="ContactName" Display="false"/>
		<DNL:ListColumn ColumnExpression="Address" Display="false"/>
		<DNL:ListColumn ColumnExpression="City" Display="false"/>
		<DNL:ListColumn ColumnExpression="Region" Display="false"/>
		<DNL:ListColumn ColumnExpression="Country" Display="false"/>
		<DNL:ListColumn ColumnExpression="Phone" Display="false"/>
		<DNL:ListColumn ColumnExpression="Fax" Display="false"/>
	</ListColumns>
</DNL:DbNetList>	

ColumnExpression

The name of the column in the Sql statement.

Display

Indicates that a column is not displayed in the list. The column value is stored as an attribute of the list row. Used for columns whose value should not be visible but available to the client-side code.

Run Sample

Format

Specifies a format mask for a date-time or numeric value.  Values are the standard .NET date-time and numeric formatting strings.

<DNL:DbNetList 
	id="DbNetList1" 
	runat="server" 
	ConnectionString = "SamplesDatabase"
	Sql = "select LastName, FirstName, BirthDate, HireDate from employees order by 1"
	HeaderRow = "true"
	RowSelection = "true"
	Style="border:1pt solid silver"
	>
	<ListColumns>
		<DNL:ListColumn ColumnExpression="BirthDate" Format="D"/>
		<DNL:ListColumn ColumnExpression="HireDate" Format="MMMM yyyy"/>
	</ListColumns>
</DNL:DbNetList>	

Run Sample

Label

Defines the text label displayed in the heading row when enabled

<DNL:DbNetList 
	id="DbNetList2" 
	runat="server" 
	ConnectionString = "SamplesDatabase"
	Sql = "select CompanyName, City, Country from customers order by 1"
	Height = "200px"
	Width = "400px"
	HeaderRow = "true"
	RowSelection = "true"
	Style="border:1pt solid silver"
	>
	<ListColumns>
		<DNL:ListColumn ColumnExpression="CompanyName" Label="Company Name"/>
	</ListColumns>
</DNL:DbNetList>		

Run Sample

Selectable

Converts the column into a selectable link in the list. An action can be linked to the selectable link using the onLinkSelected event