<html>
<head>
<title>Using the AccessDataSource Control</title>
<link rel="stylesheet" href="/shared/netdemos.css">
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Using the <span class="hilite">AccessDataSource Control</span></h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<form runat="server">
<div align="center">
<asp:accessdatasource id="ProductType" runat="server"
datafile="~/app_data/gear.mdb"
selectcommand="SELECT DISTINCT Type FROM Products"
datasourcemode="DataReader" />
<p>Select Category: <asp:dropdownlist id="filterType" runat="server"
datasourceid="ProductType" datatextfield="Type"
autopostback /></p>
<asp:accessdatasource id="Products" runat="server"
datafile="~/app_data/gear.mdb"
selectcommand="SELECT Type, ProductId, Brand, Model, Description, Price FROM Products"
filterexpression="Type='{0}'">
<filterparameters>
<asp:controlparameter controlid="filterType"
propertyname="SelectedValue" />
</filterparameters>
</asp:accessdatasource>
<asp:gridview id="ProductsGrid" runat="server"
datasourceid="Products"
autogeneratecolumns="false"
width="88%" cellpadding=5
allowpaging pagesize=6>
<headerstyle height=25pt
backcolor="sienna"
forecolor="khaki"
font-bold />
<alternatingrowstyle backcolor="beige" />
<pagersettings mode="nextprevious"
nextpagetext="Next"
previouspagetext="Back"
position="top" />
<pagerstyle backcolor="steelblue"
forecolor="beige"
horizontalalign="right" />
<columns>
<asp:templatefield headertext="Photo">
<itemtemplate>
<img src='/shared/images/gear/<%# Eval ( "ProductId" ) %>.jpg'
width=75 height=75
alt='<%# Eval ( "Model" ) %>'
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="brand"
headertext="Brand" />
<asp:boundfield datafield="model"
headertext="Model" />
<asp:boundfield datafield="description"
headertext="Description" />
<asp:boundfield datafield="price"
headertext="Price"
htmlencode=false
dataformatstring="{0:n2}"
itemstyle-horizontalalign="right" />
</columns>
</asp:gridview>
</div>
</form>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>