views:

23

answers:

2

I have an AccessDataSource TestSummaryADS. I can easily view the results in a GridView or DropDownList by setting its DataSourceID property.

How do I bind a value from the results TestSummaryADS to the text of a label?

I'm just trying to populate labels on my page with results from the DB entry.

C# or VB.NET answers okay.

+2  A: 

Use Repeater control that contains Label controls to display the values you want. Bind your DataSource control to the repeater.

Also you can use TemplateColumn with GridView and add your labels into this template column.

But IMO, Repeater control is simpler to customize your view by templates.

Canavar
+2  A: 

If you only have a single record, use a FormView

<asp:FormView ID="FormViewTestSummary" runat="server" 
DataSourceID="TestSummaryADS"
DefaultMode="Edit">
    <EditItemTemplate>
        <fieldset>           
            <asp:TextBox ID="txtMyText" Text='<%# Bind("ProjectNumber") %>' runat="server" />
MrGumbe