<html>
<head>
<title>Using a Stored Procedure with the AccessDataSource Control</title>
<link rel="stylesheet" href="/shared/netdemos.css">
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Using a <span class="hilite">Stored Procedure</span> with the <span class="hilite">AccessDataSource Control</span></h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<asp:accessdatasource id="states" runat="server"
datafile="~/app_data/usa.mdb"
selectcommand="SELECT StateId, State FROM States WHERE NOT StateId in ( 'AA', 'AE', 'AP' ) ORDER BY State"
datasourcemode="DataReader" />
<asp:accessdatasource id="counties" runat="server"
datafile="~/app_data/usa.mdb"
selectcommand="SELECT DISTINCT County FROM Zipcodes WHERE State = ? ORDER BY County"
datasourcemode="DataReader">
<selectparameters>
<asp:controlparameter controlid="lstStates"
propertyname="SelectedValue" />
</selectparameters>
</asp:accessdatasource>
<table cellpadding=3>
<tr>
<td>Select State:
<asp:dropdownlist id="lstStates" runat="server"
datasourceid="states" datatextfield="state" datavaluefield="stateid"
autopostback /></td>
<td>County:
<asp:dropdownlist id="lstCounties" runat="server"
datasourceid="counties" datatextfield="county"
autopostback /></td></tr>
</table>
<asp:accessdatasource id="zipcodes" runat="server"
datafile="~/app_data/usa.mdb"
selectcommand="[Zipcodes By State and County]"
selectcommandtype="StoredProcedure">
<selectparameters>
<asp:controlparameter controlid="lstStates"
propertyname="SelectedValue" />
<asp:controlparameter controlid="lstCounties"
propertyname="SelectedValue" />
</selectparameters>
</asp:accessdatasource>
<br>
<asp:gridview id="zipcodesGrid" runat="server"
datasourceid="zipcodes"
width=80% cellpadding=5
font-size="10pt" enableviewstate=false
alternatingrowstyle-backcolor="whitesmoke">
<headerstyle backcolor="lightsteelblue"
font-bold height=25
horizontalalign="center" />
</asp:gridview>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>