- reporting_kit_conversion_demo.zip
- reports
- bin
- ASPNETReports.dll
- ASPNETReports.dll.bak
- MySql.Data.dll
- MySql.Data.Tests.dll
- MySql.Data.xml
- ChartGenerator.aspx
- components
- crosstab.aspx
- default.aspx
- docs
- drilldown.aspx
- Global.asax
- hierarchical.aspx
- 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.gif
- logo-neg.gif
- masterdetail.gif
- masterdetaildetails.png
- masterdetails.gif
- masterdetailsummary.png
- masterdetailtables.png
- matrix.gif
- querysample.gif
- querysample2.gif
- reporting.gif
- report-table-bg.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
- masterdetail.aspx
- scripts.js
- simplereport.aspx
- sourceviewer
- 1x1.gif
- crosstab.src
- drilldown.src
- grid_background.gif
- hierarchical.src
- masterdetail.src
- simple.src
- srcview.aspx
- style.css
- tabular.src
- tabview.aspx
- textreport.src
- visual.src
- sql
- styles.css
- stylesPrint.css
- tabular.aspx
- textreport.aspx
- visual.aspx
- web.config
|
<%@ Page language="c#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="ASPNET.StarterKit.Reports.Components" %>
<script runat="server">
//*********************************************************************
//
// SimpleReport.aspx
//
// This report lists all customer contacts information from the database
// in a DataGrid control
//
//*********************************************************************
protected string _styleSheet;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
// switches the style sheet based on printer friendly view or not
if (Request.QueryString["Print"]=="true")
{
_styleSheet = "stylesPrint.css";
PrintButton.Visible = true;
PagingButton.Visible = true;
}
else
{
_styleSheet = "styles.css";
}
}
//*********************************************************************
//
// The BindGrid method retrieves a collection of simple report items
// and databinds it to the CustomerGrid
//
//*********************************************************************
private void BindGrid()
{
SimpleReportCollection customerList = SimpleReport.GetCustomerContacts();
SortGridData(customerList, SortField, SortAscending);
CustomerGrid.DataSource = customerList;
CustomerGrid.DataBind();
}
//*********************************************************************
//
// The SortGrid event handler changes the sortfield for the Customer grid
// and re-binds it.
//
//*********************************************************************
private void CustomerGrid_Sort(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
// change sort field
SortField = (string)e.SortExpression;
// re-bind to display new sorting
BindGrid();
}
//*******************************************************
//
// SortGridData methods sorts the datagrid based on which
// sort field is being selected. Also does reverse sorting based on the boolean.
//
//*******************************************************
private void SortGridData(SimpleReportCollection list, string sortField, bool asc)
{
SimpleReportCollection.SimpleReportFields sortCol = SimpleReportCollection.SimpleReportFields.InitValue;
switch(sortField)
{
case "City":
sortCol = SimpleReportCollection.SimpleReportFields.City;
break;
case "CompanyName":
sortCol = SimpleReportCollection.SimpleReportFields.CompanyName;
break;
case "ContactName":
sortCol = SimpleReportCollection.SimpleReportFields.ContactName;
break;
case "ContactTitle":
sortCol = SimpleReportCollection.SimpleReportFields.ContactTitle;
break;
case "Phone":
sortCol = SimpleReportCollection.SimpleReportFields.Phone;
break;
}
list.Sort(sortCol, asc);
}
//*******************************************************
//
// CustomerGrid_PageIndexChanged server event handler on this page is used
// for changing page index
//
//*******************************************************
private void CustomerGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
CustomerGrid.CurrentPageIndex = e.NewPageIndex;
BindGrid();
}
//*******************************************************
//
// pagingButton_Click server event handler on this page is used
// for changing paging property on CustomerGrid
//
//*******************************************************
private void pagingButton_Click(object sender, System.EventArgs e)
{
CustomerGrid.AllowPaging = !CustomerGrid.AllowPaging;
BindGrid();
PagingButton.Text = CustomerGrid.AllowPaging ? "Disable Paging" : "Enable Paging";
}
string SortField
{
get
{
object o = ViewState["SortField"];
if (o == null)
{
return String.Empty;
}
return (string)o;
}
set
{
if (value == SortField)
{
// same as current sort file, toggle sort direction
SortAscending = !SortAscending;
}
ViewState["SortField"] = value;
}
}
//*********************************************************************
//
// SortAscending property is tracked in ViewState
//
//*********************************************************************
bool SortAscending
{
get
{
object o = ViewState["SortAscending"];
if (o == null)
{
return true;
}
return (bool)o;
}
set
{
ViewState["SortAscending"] = value;
}
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Simple Report</title>
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<link href="<%= _styleSheet %>" type=text/css rel=stylesheet>
<script src="scripts.js"></script>
</head>
<body class="Report" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<form id="Simple" method="post" runat="server">
<table width="100%" cellpadding="0" cellspacing="0">
<tr height="20">
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="4"><img src="images/spacer.gif" width="50" height="20"></td>
</tr>
<tr>
<td width="20"></td>
<td class="ReportTitle">Customer Contacts</td>
<td align="right">
<asp:LinkButton id="PagingButton" runat="server" cssclass="printbutton" Visible="False" OnClick="pagingButton_Click">Disable Paging</asp:LinkButton>
<asp:hyperlink id="PrintButton" navigateurl="javascript:Print()" cssclass="printbutton" runat="server" visible="False">Print</asp:hyperlink></td>
<td width="20"></td>
</tr>
<tr>
<td colspan="4"><img src="images/spacer.gif" width="20" height="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="20"></td>
<td>
<asp:datagrid id="CustomerGrid" OnPageIndexChanged="CustomerGrid_PageIndexChanged" OnSortCommand="CustomerGrid_Sort" AlternatingItemStyle-CssClass="Content" runat="server" AutoGenerateColumns="False" BorderWidth="0" GridLines="None" Width="100%" AllowSorting="True" AllowPaging="True" PageSize="20" CellPadding="5">
<alternatingitemstyle cssclass="Content"></alternatingitemstyle>
<columns>
<asp:BoundColumn DataField="CompanyName" SortExpression="CompanyName" HeaderText="Company">
<headerstyle cssclass="CategoryHeader"></headerstyle>
<itemstyle cssclass="ItemStyle"></itemstyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="ContactName" SortExpression="ContactName" HeaderText="Contact">
<headerstyle cssclass="CategoryHeader"></headerstyle>
<itemstyle cssclass="ItemStyle"></itemstyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="ContactTitle" SortExpression="ContactTitle" HeaderText="Title">
<headerstyle cssclass="CategoryHeader"></headerstyle>
<itemstyle cssclass="ItemStyle"></itemstyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Phone" SortExpression="Phone" HeaderText="Telephone">
<headerstyle cssclass="CategoryHeader"></headerstyle>
<itemstyle cssclass="ItemStyle"></itemstyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="City" SortExpression="City" HeaderText="City">
<headerstyle cssclass="CategoryHeader"></headerstyle>
<itemstyle cssclass="ItemStyle"></itemstyle>
</asp:BoundColumn>
</columns>
</asp:datagrid>
</td>
<td width="20"></td>
</tr>
</table>
</form>
</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.
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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.