ttist25
asked on
Beginner - How to populate asp literal from Access database
Hey there,
I'm trying to populate an asp literal control on my asp.net page with data from an Access database.
I've got this to connect to my database:
<asp:AccessDataSource id="AccessDataSource2" runat="server" DataFile="app_data/pedigre es.mdb" SelectCommand="SELECT [Horse] FROM [Pedigrees] WHERE ([ID] = ?)">
<SelectParameters>
<asp:parameter DefaultValue="1" Name="ID" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
I'd like to use an asp literal to get the value of "Horse" and display it on my page.
Any help will be greatly appreciated.
PS - I don't have a clue what I'm doing.
I'm trying to populate an asp literal control on my asp.net page with data from an Access database.
I've got this to connect to my database:
<asp:AccessDataSource id="AccessDataSource2" runat="server" DataFile="app_data/pedigre
<SelectParameters>
<asp:parameter DefaultValue="1" Name="ID" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
I'd like to use an asp literal to get the value of "Horse" and display it on my page.
Any help will be greatly appreciated.
PS - I don't have a clue what I'm doing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I ended up doing this which works:
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="AccessDataSo urce2">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Horse") %>' />
</ItemTemplate>
</asp:Repeater>
It seems like if the asp:Label had a "DataSourceID" property it would make things really simple. Am I missing something or is it really that complicated?
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="AccessDataSo
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Horse") %>' />
</ItemTemplate>
</asp:Repeater>
It seems like if the asp:Label had a "DataSourceID" property it would make things really simple. Am I missing something or is it really that complicated?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is there any reason behind using a <asp:Literal>. If not why not use a TextBOx or a Label.