Click here to Skip to main content
15,883,705 members
Articles / Web Development / HTML

ASP.NET Reports Starter Kits Porting from Windows to Linux (Race to Linux)

Rate me:
Please Sign up or sign in to vote.
3.30/5 (4 votes)
30 Sep 20055 min read 33.7K   19  
ASP.NET Reports Starter Kit Porting from Windows to Linux using Mainsoft's Grasshopper
<html>
	<head>
		<title>ASP.NET Reports Starter Kit Documentation</title>
		<link href="style.css" type="text/css" rel="stylesheet">
	</head>
	<body class="NormalIndent">
		<h1>
			DrillDown Report
		</h1>
		<p>
			<b>Description:</b> &nbsp;&nbsp;&nbsp;The drilldown report displays customer 
			shipped order information. Users are presented with a list of customers. From 
			there, they can click on a customer and see the orders shipped to that 
			customer. Furthermore, they can click on an order ID to view the details 
			for&nbsp;that particular order.
		</p>
		<p>
			<strong>Overview:</strong>&nbsp;&nbsp;&nbsp;The drilldown report shows a way of 
			displaying a hierarchy of data, in this instance customers --&gt; orders --&gt; 
			order details.
		</p>
		<p>
			<strong>Implementation Notes:&nbsp;</strong> &nbsp; The list of customers is a 
			Datalist. Inside of the selected template for the Customers Datalist is the 
			Orders Datalist. And inside of the Orders Datalist's selected template is the 
			Order Details Datagrid. The selected template determines the content and layout 
			of the selected item of datalist.
		</p>
		<p>
			<img src="./images/1x1.gif" width="25"> <img src="./images/DrillDownNestedControls.png">
		</p>
		<p>
			The Datalist is used for the customers and orders list because of its selected 
			template feature. The Datagrid is used to easily display the Order details 
			since it does not require a selected template.
		</p>
		<pre>
	<font color=red>&lt;asp:datalist id="CustomerList" runat="server" ... &gt;</font>
		...
		<font color=blue>&lt;selecteditemtemplate&gt;</font>
			<font color=red>&lt;asp:datalist id="OrderList" runat="server" <font color=blue>DataSource='&lt;%# GetOrders((string)DataBinder.Eval(Container.DataItem, "CustomerID"))</font> %&gt;' &gt;</font>
				...
				<font color=blue>&lt;selecteditemtemplate&gt;</font>
					<font color=red>&lt;asp:datagrid id=OrderDetailsGrid runat="server" <font color=blue>DataSource='&lt;%# GetOrderDetails((int)DataBinder.Eval(Container.DataItem, "OrderID"))</font> %&gt;' &gt;</font>
						&lt;columns&gt;
							&lt;asp:boundcolumn DataField="ProductName" HeaderText="Product" ... &gt;&lt;/asp:boundcolumn&gt;
							&lt;asp:boundcolumn DataField="UnitPrice" HeaderText="Unit Price" DataFormatString="{0:c}" ... &gt;&lt;/asp:boundcolumn&gt;
							&lt;asp:boundcolumn DataField="Quantity" HeaderText="Quantity" ... &gt;&lt;/asp:boundcolumn&gt;
						&lt;/columns&gt;
					&lt;/asp:datagrid&gt;
				&lt;/selecteditemtemplate&gt;
			&lt;/asp:datalist&gt;
		&lt;/selecteditemtemplate&gt;
	&lt;/asp:datalist&gt;
		</pre>
		<p>To show the selected itemtemplate, an event is added to the CustomerList. An 
			event handler is also added to the OrdersList. The event handler looks to see 
			if a "select" command is called and sets the selected index of the 
			corresponding Datalist and then re-binds the Datalist.</p>
		<pre>
	&lt;asp:datalist id="CustomerList" runat="server" ...  <font color=blue>OnItemCommand="DataList_ItemCommand"</font> &gt;
		...
		&lt;itemtemplate&gt;
			<font color=red>&lt;asp:linkbutton id="button1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CompanyName") %>' CommandName="select" /&gt;</font>
		&lt;/itemtemplate&gt;
		&lt;selecteditemtemplate&gt;
			&lt;asp:datalist id="OrderList" runat="server" <font color=blue>OnItemCommand="OrdersList_ItemCommand"</font> %&gt;' &gt;</FONT>
				...
				&lt;itemtemplate&gt;
					<font color=red>&lt;asp:linkbutton id="Linkbutton1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "OrderID") %>' CommandName="select" /&gt;</font>
				&lt;/itemtemplate&gt;
				&lt;selecteditemtemplate&gt;
					&lt;asp:datagrid id=OrderDetailsGrid runat="server" ... %&gt;' &gt;</FONT>
						&lt;columns&gt;
							&lt;asp:boundcolumn DataField="ProductName" HeaderText="Product" ... &gt;&lt;/asp:boundcolumn&gt;
							&lt;asp:boundcolumn DataField="UnitPrice" HeaderText="Unit Price" DataFormatString="{0:c}" ... &gt;&lt;/asp:boundcolumn&gt;
							&lt;asp:boundcolumn DataField="Quantity" HeaderText="Quantity" ... &gt;&lt;/asp:boundcolumn&gt;
						&lt;/columns&gt;
					&lt;/asp:datagrid&gt;
				&lt;/selecteditemtemplate&gt;
			&lt;/asp:datalist&gt;
		&lt;/selecteditemtemplate&gt;
	&lt;/asp:datalist&gt;
		</pre>
		<p>Since the Orders Datalist is inside of the Customers Datalist's selected 
			template, it is dynamically generated as the Customers Datalist is data 
			binding. The Customers Datalist passes in the customer ID of the selected 
			customer to the Orders Datalist. The Orders DataList then binds to the orders 
			for that selected customer.</p>
		<p>The customer ID is placed in a hidden label control so that it can be retrieve 
			in the OnItemCommand event of the Customers Datalist.
		</p>
		<pre>
	&lt;asp:label id="CustomerID" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem, "CustomerID") %&gt;' Visible=False /&gt;
		</pre>
		<p>The customer ID is saved in ViewState in the OnItemCommand event of the Customers Datalist. The 
			customer ID must be saved so that when the Orderlist selected index changes, 
			it can re-bind to the correct customer. It is retrieved when the page 
			is posted back and the OnItemCommand event is raised for the Orders Datalist.
		</p>
		<pre>			
	protected void DataList_ItemCommand(object Sender, DataListCommandEventArgs e) 
	{
		// change the Datalist to selected index
		string cmd = ((LinkButton)e.CommandSource).CommandName;
		if (cmd == "select")
			((DataList)Sender).SelectedIndex = e.Item.ItemIndex;

		// re-bind to display data with the new selected index
		BindList();

		<font color=blue>// store the customer id to re-bind in the orders list
		ViewState[_customerID] = ((Label)e.Item.FindControl("CustomerID")).Text;</font>
	}
		</pre>
		<pre>
	protected void OrdersList_ItemCommand(object Sender, DataListCommandEventArgs e) 
	{
		// change the selected index of Orders Datalist
		string cmd = ((LinkButton)e.CommandSource).CommandName;
		DataList sender = (DataList)Sender;
		if (cmd == "select")
			sender.SelectedIndex = e.Item.ItemIndex;

		<font color=blue>// re-bind to display orders info with new selected index.
		sender.DataSource = GetOrders((string)ViewState[_customerID]);
		sender.DataBind();</font>
	}		
		</pre>
	</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Australia Australia
"Impossible" + "'" + " " = "I'm Possible"

Started programming when i was a kid with 286 computers and Spectrum using BASIC from 1986. There was series of languages like pascal, c, c++, ada, algol, prolog, assembly, java, C#, VB.NET and so on. Then shifted my intrest in Architecture during past 5 years with Rational Suite and UML. Wrote some articles, i was member of month on some sites, top poster(i only answer) of week (actually weeks), won some books as prizes, rated 2nd in ASP.NET and ADO.NET in Australia.

There is simplicity in complexity

Comments and Discussions