Link to home
Start Free TrialLog in
Avatar of ttist25
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/pedigrees.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.
Avatar of M3mph15
M3mph15
Flag of Australia image

Hi,

Is there any reason behind using a <asp:Literal>. If not why not use a TextBOx or a Label.
ASKER CERTIFIED SOLUTION
Avatar of Christian de Bellefeuille
Christian de Bellefeuille
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ttist25
ttist25

ASKER

I ended up doing this which works:

<asp:Repeater ID="Repeater1" runat="server"
        DataSourceID="AccessDataSource2">
            <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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial