Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Conversion of Reporting Starter Kit to use Mono/MySQL

, 1 Oct 2005
A porting of the ASP.NET reporting starter kit to use Mono, MySQL and Apache on a Linux system.
Reporting_Kit_Conversion_demo.zip
reports
bin
ASPNETReports.dll
ASPNETReports.dll.bak
MySql.Data.dll
MySql.Data.Tests.dll
components
bin
Release
ASPNETReports.dll
BLL
DAL
docs
images
1x1.gif
crosstabnestedcontrols.png
crosstabtotals.png
customers.gif
drilldownnestedcontrols.png
employees.gif
getorderdetails.gif
GetOrders.gif
hierarchicalpaging.gif
hierarchicalreport.gif
hierarchicalschema.gif
hierarchicalsorting.gif
masterdetaildetails.png
masterdetailsummary.png
masterdetailtables.png
querysample.gif
querysample2.gif
simpleoverview.png
simplesp.png
tabcolorcode.png
tabdetail.png
tabheader.gif
tabheader.png
tabnestedcontrols.png
tabsortshot.png
tabularextendedprice.png
textshot.gif
viscategorysales.gif
viscategorysales.png
vischartstructure.png
xtabsql.png
Global.asax
images
1x1.gif
asp.net-reports.gif
background.gif
crosstab.gif
crosstabnestedcontrols.png
crosstabtotals.png
customers.gif
drilldown.gif
drilldownnestedcontrols.png
employees.gif
getorderdetails.gif
GetOrders.gif
grid_background.gif
hierarchal.gif
hierarchical.gif
hierarchicalpaging.gif
hierarchicalreport.gif
hierarchicalschema.gif
hierarchicalsorting.gif
logo-neg.gif
logo.gif
masterdetail.gif
masterdetaildetails.png
masterdetails.gif
masterdetailsummary.png
masterdetailtables.png
matrix.gif
querysample.gif
querysample2.gif
report-table-bg.gif
reporting.gif
simple.gif
simpleoverview.png
simplesp.png
spacer.gif
tabcolorcode.png
tabdetail.png
tabheader.gif
tabheader.png
tabnestedcontrols.png
tabsortshot.png
tabular.gif
tabularcolorcode.png
tabularextendedprice.png
tabularsorting.png
text.gif
textalternate.gif
textreport.gif
textshot.gif
viscategorysales.gif
viscategorysales.png
vischartstructure.png
visual.gif
xtabsql.png
sourceviewer
1x1.gif
crosstab.src
drilldown.src
grid_background.gif
hierarchical.src
masterdetail.src
simple.src
tabular.src
textreport.src
visual.src
sql
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
&lt%@ Page language="c#" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="System" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="System.Web.UI.WebControls" %<font color= "blue">&gt</font>
&lt%@ Import Namespace="ASPNET.StarterKit.Reports.Components" %<font color= "blue">&gt</font>

<font color= "blue">&lt</font><font color="maroon">script</font> runat="server"<font color= "blue">&gt</font>
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // Tabular.aspx</font>
<font color= "green">    //</font>
<font color= "green">    // The Tabular.aspx page shows a basic technique for grouping related data </font>
<font color= "green">    // (in this case, grouping products by category). This is accomplished by nesting a </font>
<font color= "green">    // DataGrid control inside a DataList control. Additionally, this report demonstrates </font>
<font color= "green">    // how easy it is to implement interactive sorting in the report using ASP.NET.</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue">    </font>
<font color= "blue">    protected </font>string _styleSheet;
<font color= "blue">    </font>
<font color= "blue">    private void</font> Page_Load(object sender, System.EventArgs e)
<font color= "blue">    </font>{
<font color= "blue"></font><font color= "blue">        if </font>(!IsPostBack)<font color= "blue"></font>
<font color= "blue">        </font>{
<font color= "green">            // default sort will be by product name</font>
<font color= "blue"></font><font color= "blue">            if </font>(SortField == "") <font color= "blue"></font>
<font color= "blue">                </font>SortField = "ProductName";
<font color= "blue"></font>
<font color= "blue">            </font>BindList();
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "green">        // switches the style sheet based on printer friendly view or not</font>
<font color= "blue"></font><font color= "blue">        if </font>(Request.QueryString["Print"]=="true")<font color= "blue"></font>
<font color= "blue">        </font>{
<font color= "blue">            </font>_styleSheet = "stylesPrint.css";
<font color= "blue">            </font>PrintButton.Visible = true;
<font color= "blue">        </font>}
<font color= "blue"></font><font color= "blue">        else </font><font color= "blue"></font>
<font color= "blue">        </font>{
<font color= "blue">            </font>_styleSheet = "styles.css";
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // The BindList method retrieves the list of categories</font>
<font color= "green">    // and then data binds them to the ProductsByCategoryList</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    private void</font> BindList()
<font color= "blue">    </font>{
<font color= "blue">        </font>CategoriesList.DataSource = TabularReport.GetCategories();
<font color= "blue">        </font>CategoriesList.DataBind();
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // The GetDetails method calls the BLL to retrieve product for a category given</font>
<font color= "green">    // a category id.</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    protected </font>TabularReportCollection GetDetails(int categoryID)
<font color= "blue">    </font>{
<font color= "blue">        </font>TabularReportCollection detailList = TabularReport.GetProducts(categoryID);
<font color= "blue"></font>
<font color= "green">        // do the sorting if there are data returned</font>
<font color= "blue"></font><font color= "blue">        if </font>(detailList.Count > 0) <font color= "blue"></font>
<font color= "blue">            </font>SortGridData(detailList, SortField, SortAscending);
<font color= "blue"></font>
<font color= "blue">        return</font> detailList;
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "green">    //*******************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // SortGridData methods sorts the datagrid based on which</font>
<font color= "green">    // sort field is being selected.  Also does reverse sorting based on the boolean.</font>
<font color= "green">    //</font>
<font color= "green">    //*******************************************************</font>
<font color= "blue"></font>
<font color= "blue">    private void</font> SortGridData(TabularReportCollection list, string sortField, bool asc)
<font color= "blue">    </font>{
<font color= "blue">        </font>TabularReportCollection.TabularReportFields sortCol = TabularReportCollection.TabularReportFields.InitValue;
<font color= "blue"></font>
<font color= "blue">        </font>switch(sortField)
<font color= "blue">        </font>{
<font color= "blue">            case</font> "ProductName":
<font color= "blue">                </font>sortCol = TabularReportCollection.TabularReportFields.ProductName;
<font color= "blue">                </font>break;
<font color= "blue">            case</font> "UnitPrice":
<font color= "blue">                </font>sortCol = TabularReportCollection.TabularReportFields.UnitPrice;
<font color= "blue">                </font>break;
<font color= "blue">            case</font> "UnitsInStock":
<font color= "blue">                </font>sortCol = TabularReportCollection.TabularReportFields.UnitsInStock;
<font color= "blue">                </font>break;
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        </font>list.Sort(sortCol, asc);
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "green">    //*******************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // CalculateExtendedPrice event handler is tied to the OnItemDataBound of the Datagrid.</font>
<font color= "green">    // It retrieves the unit price and multiplies that to the units in stock to calculate the extended price of a product.</font>
<font color= "green">    // The extended price is displayed as the right most column.</font>
<font color= "green">    //</font>
<font color= "green">    //*******************************************************</font>
<font color= "blue"></font>
<font color= "blue">    protected void</font> CalculateExtendedPrice(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
<font color= "blue">    </font>{
<font color= "blue"></font><font color= "blue">        if </font>(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)<font color= "blue"></font>
<font color= "blue">        </font>{
<font color= "blue">            </font>double unitsInStock = Convert.ToDouble(e.Item.Cells[1].Text);
<font color= "blue">            </font>double unitPrice =  Convert.ToDouble(e.Item.Cells[4].Text);
<font color= "blue">            </font>e.Item.Cells[5].Text = string.Format("{0:c}", unitPrice * unitsInStock);
<font color= "blue"></font>
<font color= "green">            // format unit price column as currency</font>
<font color= "blue">            </font>e.Item.Cells[4].Text = string.Format("{0:c}", unitPrice);
<font color= "blue"></font>
<font color= "green">            // if there are no units in stock, color the line item as red by changing the style class</font>
<font color= "blue"></font><font color= "blue">            if </font>(unitsInStock == 0)<font color= "blue"></font>
<font color= "blue">                </font>e.Item.CssClass = "OutOfStock";
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // The SortGrid event handler changes the sortfield for the Projects grid </font>
<font color= "green">    // and re-binds it.</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    protected void</font> SortGrid(Object sender, DataGridSortCommandEventArgs e) 
<font color= "blue">    </font>{
<font color= "green">        // change sort field</font>
<font color= "blue">        </font>SortField = (string)e.SortExpression;
<font color= "blue"></font>
<font color= "green">        // re-bind to display new sorting</font>
<font color= "blue">        </font>BindList();
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "blue">    </font>string SortField 
<font color= "blue">    </font>{
<font color= "blue">        get</font> 
<font color= "blue">        </font>{
<font color= "blue">            </font>object o = ViewState["SortField"];
<font color= "blue"></font><font color= "blue">            if </font>(o == null) <font color= "blue"></font>
<font color= "blue">            </font>{
<font color= "blue">                return</font> String.Empty;
<font color= "blue">            </font>}
<font color= "blue">            return</font> (string)o;
<font color= "blue">        </font>}
<font color= "blue">        set</font> 
<font color= "blue">        </font>{
<font color= "blue"></font><font color= "blue">            if </font>(value == SortField) <font color= "blue"></font>
<font color= "blue">            </font>{
<font color= "green">                // same as current sort file, toggle sort direction</font>
<font color= "blue">                </font>SortAscending = !SortAscending;
<font color= "blue">            </font>}
<font color= "blue">            </font>ViewState["SortField"] = value;
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue"></font>
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // SortAscending property is tracked in ViewState</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    </font>bool SortAscending 
<font color= "blue">    </font>{
<font color= "blue">        get</font> 
<font color= "blue">        </font>{
<font color= "blue">            </font>object o = ViewState["SortAscending"];
<font color= "blue"></font>
<font color= "blue"></font><font color= "blue">            if </font>(o == null) <font color= "blue"></font>
<font color= "blue">            </font>{
<font color= "blue">                return</font> true;
<font color= "blue">            </font>}
<font color= "blue">            return</font> (bool)o;
<font color= "blue">        </font>}
<font color= "blue">        set</font> 
<font color= "blue">        </font>{
<font color= "blue">            </font>ViewState["SortAscending"] = value;
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue">&lt/</font><font color="maroon">script</font><font color= "blue">&gt</font>

<font color= "blue">&lt!</font><font color="maroon">DOCTYPE</font> HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" <font color= "blue">&gt</font>
<font color= "blue">&lt</font><font color="maroon">HTML</font><font color= "blue">&gt</font>
    <font color= "blue">&lt</font><font color="maroon">HEAD</font><font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">title</font><font color= "blue">&gt</font>Tabular<font color= "blue">&lt/</font><font color="maroon">title</font><font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">meta</font> content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">link</font> href="&lt%= _styleSheet %<font color= "blue">&gt</font>" type=text/css rel=stylesheet<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">script</font> src="scripts.js"<font color= "blue">&gt</font><font color= "blue">&lt/</font><font color="maroon">script</font><font color= "blue">&gt</font>
    <font color= "blue">&lt/</font><font color="maroon">HEAD</font><font color= "blue">&gt</font>
    <font color= "blue">&lt</font><font color="maroon">body</font> class="Report" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0"<font color= "blue">&gt</font>
        <font color= "blue">&lt</font><font color="maroon">form</font> id="Tabular" method="post" runat="server"<font color= "blue">&gt</font>
            <font color= "blue">&lt</font><font color="maroon">table</font> border="0" cellpadding="5" cellspacing="15" width="100%"<font color= "blue">&gt</font>
                <font color= "blue">&lt</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                    <font color= "blue">&lt</font><font color="maroon">td</font> class="ReportTitle"<font color= "blue">&gt</font>Products By Category<font color= "blue">&lt/</font><font color="maroon">td</font><font color= "blue">&gt</font>
                    <font color= "blue">&lt</font><font color="maroon">td</font> align="right"<font color= "blue">&gt</font><font color= "blue">&lt</font><font color=blue>asp:HyperLink id="PrintButton" NavigateUrl="javascript:Print()" CssClass="printbutton" runat="server" Visible="False"<font color= "blue">&gt</font>Print<font color= "blue">&lt/</font>asp:HyperLink<font color= "blue">&gt</font><font color= "blue">&lt/</font><font color="maroon">td</font></font><font color= "blue">&gt</font>
                <font color= "blue">&lt/</font><font color="maroon">tr</font><font color= "blue">&gt</font>
            <font color= "blue">&lt/</font><font color="maroon">table</font><font color= "blue">&gt</font>
            <font color= "blue">&lt</font><font color=blue>asp:datalist id="CategoriesList" runat="server" RepeatDirection="Vertical" repeatcolumns="1" Width="100%" CellPadding="5" cellspacing="15"</font><font color= "blue">&gt</font>
                <font color= "blue">&lt</font><font color="maroon">itemtemplate</font><font color= "blue">&gt</font>
                    <font color= "blue">&lt</font><font color="maroon">table</font> border="0" cellpadding="3" cellspacing="0" class="Content" width="100%"<font color= "blue">&gt</font>
                        <font color= "blue">&lt</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                            <font color= "blue">&lt</font><font color="maroon">td</font> valign="top" class="CategoryHeader"<font color= "blue">&gt</font>
                                Category
                                &lt%# DataBinder.Eval(Container.DataItem, "CategoryName") %<font color= "blue">&gt</font>
                            <font color= "blue">&lt/</font><font color="maroon">td</font><font color= "blue">&gt</font>
                        <font color= "blue">&lt/</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                        <font color= "blue">&lt</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                            <font color= "blue">&lt</font><font color="maroon">td</font><font color= "blue">&gt</font>
                                <font color= "blue">&lt</font><font color=blue>asp:datagrid id=Datagrid1 runat="server" autogeneratecolumns="False" DataSource='&lt%# GetDetails((int)DataBinder.Eval(Container.DataItem, "CategoryID")) %<font color= "blue">&gt</font>' OnItemDataBound="CalculateExtendedPrice" BorderWidth="0" GridLines="None" AllowSorting="true" OnSortCommand="SortGrid" Width="100%"</font><font color= "blue">&gt</font>
                                    <font color= "blue">&lt</font><font color="maroon">columns</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt</font><font color=blue>asp:boundcolumn DataField="ProductName" HeaderText="Product" SortExpression="ProductName" ItemStyle-CssClass="ItemStyle" HeaderStyle-CssClass="ProductHeader" ItemStyle-Width="200"<font color= "blue">&gt</font><font color= "blue">&lt/</font>asp:boundcolumn</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt</font><font color=blue>asp:boundcolumn DataField="UnitsInStock" HeaderText="Units In Stock" ItemStyle-CssClass="ItemStyleRight" HeaderStyle-CssClass="ProductHeaderRight" SortExpression="UnitsInStock"<font color= "blue">&gt</font><font color= "blue">&lt/</font>asp:boundcolumn</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt</font><font color=blue>asp:templatecolumn</font><font color= "blue">&gt</font>
                                            <font color= "blue">&lt</font><font color="maroon">itemtemplate</font><font color= "blue">&gt</font>
                                                <font color= "blue">&lt</font><font color="maroon">img</font> src="images/spacer.gif" width="70" height="1" <font color= "blue">/&gt</font>
                                            <font color= "blue">&lt/</font><font color="maroon">itemtemplate</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt/</font><font color=blue>asp:templatecolumn</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt</font><font color=blue>asp:boundcolumn DataField="QuantityPerUnit" HeaderText="Quantity Per Unit" ItemStyle-CssClass="ItemStyle" HeaderStyle-CssClass="ProductHeader"<font color= "blue">&gt</font><font color= "blue">&lt/</font>asp:boundcolumn</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt</font><font color=blue>asp:boundcolumn DataField="UnitPrice" HeaderText="Unit Price" ItemStyle-CssClass="ItemStyleRight" HeaderStyle-CssClass="ProductHeaderRight" SortExpression="UnitPrice"<font color= "blue">&gt</font><font color= "blue">&lt/</font>asp:boundcolumn</font><font color= "blue">&gt</font>
                                        <font color= "blue">&lt</font><font color=blue>asp:boundcolumn HeaderText="Extended Price" ItemStyle-CssClass="ItemStyleRight" HeaderStyle-CssClass="ProductHeaderRight"<font color= "blue">&gt</font><font color= "blue">&lt/</font>asp:boundcolumn</font><font color= "blue">&gt</font>
                                    <font color= "blue">&lt/</font><font color="maroon">columns</font><font color= "blue">&gt</font>
                                <font color= "blue">&lt/</font><font color=blue>asp:datagrid</font><font color= "blue">&gt</font>
                            <font color= "blue">&lt/</font><font color="maroon">td</font><font color= "blue">&gt</font>
                        <font color= "blue">&lt/</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                        <font color= "blue">&lt</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                            <font color= "blue">&lt</font><font color="maroon">td</font> class="CategoryFooter"<font color= "blue">&gt</font>
                                Total Units in Stock:
                                &lt%# DataBinder.Eval(Container.DataItem, "TotalInStock") %<font color= "blue">&gt</font>
                            <font color= "blue">&lt/</font><font color="maroon">td</font><font color= "blue">&gt</font>
                        <font color= "blue">&lt/</font><font color="maroon">tr</font><font color= "blue">&gt</font>
                    <font color= "blue">&lt/</font><font color="maroon">table</font><font color= "blue">&gt</font>
                <font color= "blue">&lt/</font><font color="maroon">itemtemplate</font><font color= "blue">&gt</font>
                <font color= "blue">&lt</font><font color="maroon">headerstyle</font> cssclass="ReportTitle"<font color= "blue">&gt</font><font color= "blue">&lt/</font><font color="maroon">headerstyle</font><font color= "blue">&gt</font>
            <font color= "blue">&lt/</font><font color=blue>asp:datalist</font><font color= "blue">&gt</font>
        <font color= "blue">&lt/</font><font color="maroon">form</font><font color= "blue">&gt</font>
    <font color= "blue">&lt/</font><font color="maroon">body</font><font color= "blue">&gt</font>
<font color= "blue">&lt/</font><font color="maroon">HTML</font><font color= "blue">&gt</font>
</pre>

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

Share

About the Author

StylezHouse
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 1 Oct 2005
Article Copyright 2005 by StylezHouse
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid