Reputation: 661
I haven't been able to get any of my queries to work. They work when I use them in Access. For some reason, I just can't get them to work for my website. Am I missing some code behind or something? Is there any code behind I should have when I'm using a QueryString Parameter? Here are my previous posts about my previous queries:
Here is my current query and the associated ASP code:
StreetPhoto.aspx
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="~/App_Data/TravelJoansDB.accdb"
SelectCommand="SELECT * FROM [StreetPhotos]">
</asp:AccessDataSource>
<asp:DataList ID="DataList2" runat="server"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="30"
CellSpacing="2" DataKeyField="ID" DataSourceID="AccessDataSource2"
GridLines="Both" RepeatColumns="3" RepeatDirection="Horizontal">
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<ItemStyle BackColor="White" />
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "StreetPic.aspx?ID=" + Eval("ID") %>'>
<asp:Image ID="Image1" runat="server" AlternateText="Street Photo"
BorderWidth="1px"
Width="220px"
Height="180"
ImageUrl='<%# "PlaceImages/" + Eval("picPath") %>' />
</asp:HyperLink>
</ItemTemplate>
<SelectedItemStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
</asp:DataList>
And here is the StreetPic.aspx page that is linked to the above code:
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="~/App_Data/TravelJoansDB.accdb"
SelectCommand="SELECT * FROM [StreetPhotos] WHERE ([ID] = @ID)">
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
<table class="streetTableStyle">
<tr>
<td>
<asp:Image ID="Image1" runat="server" AlternateText="Street Picture" BorderWidth="1px" ImageUrl='<%# "PlaceImages/" + Eval("picPath") %>' />
</td>
</tr>
<tr>
<td>
<asp:Label ID="TextBox1" runat="server" Text='<%# Eval("picCaption") %>' />
</td>
</tr>
</table>
Upvotes: 1
Views: 78
Reputation: 9414
You must placed table into a formView that bind to AccessDataSource
<asp:FormView ID="FormView1" runat="server" DataSourceID="AccessDataSource2">
<ItemTemplate>
<table class="streetTableStyle">
<tr>
<td>
<asp:Image ID="Image1" runat="server" AlternateText="Street Picture" BorderWidth="1px" ImageUrl='<%# "PlaceImages/" + Eval("picPath") %>' />
</td>
</tr>
<tr>
<td>
<asp:Label ID="TextBox1" runat="server" Text='<%# Eval("picCaption") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>
Upvotes: 1