Solved

Explain how DataRepeater Container gets data from DataSource

Posted on 2010-11-13
4
1,014 Views
Last Modified: 2012-05-10
Hi Experts,

I was wondering if someone could explain to me the Container class on http://www.w3schools.com/ASPNET/aspnet_repeater.asp

They don't seem to import / reference any other classes, and when I try doing the same thing I am getting an error:
Container' is not declared. It may be inaccessible due to its protection level.

Thanks so much
<form id="Form1" runat="server">
<asp:Repeater runat="server" ID="rpCategory">
    <ItemTemplate>
    <tr>
        <td>
            <asp:RadioButton GroupName="rbLstCategory" runat="server" Text="<% Databinder.Eval(Container.DataItem, "Title", "{0:d}") %>" ></asp:RadioButton>
            </td>
    </tr>
    <tr>
        <td>
            <% DataBinder.Eval(Container.DataItem, "Description", "{0:d}")%>
        </td>
    </tr>
    </ItemTemplate>
</asp:Repeater>
</form>

-- Code Behind --
Private Sub BindRepeater()

	Dim ctl As New myQuestionCategoryController

	Dim arr As ArrayList = ctl.myQuestionCategoryGetByModules(Me.MainModuleID, False, False)

	Me.rpCategory.DataSource = arr
	Me.rpCategory.DataBind()

End Sub

Open in new window

0
Comment
Question by:Craig Lambie
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
What version of .Net are you using?
0
 
LVL 16

Accepted Solution

by:
BurnieP earned 200 total points
Comment Utility
When you bind using Eval you need to use <%# and not only <%

You are using :

<% DataBinder.Eval(Container.DataItem, "Description", "{0:d}")%>

Where it should be  :

<%# DataBinder.Eval(Container.DataItem, "Description", "{0:d}")%>

I modified your code with the right syntax.

Hope it helps.
<form id="Form1" runat="server">

<asp:Repeater runat="server" ID="rpCategory">

    <ItemTemplate>

    <tr>

        <td>

            <asp:RadioButton GroupName="rbLstCategory" runat="server" Text='<%# Databinder.Eval(Container.DataItem, "Title", "{0:d}") %>' ></asp:RadioButton>

            </td>

    </tr>

    <tr>

        <td>

            <%# DataBinder.Eval(Container.DataItem, "Description", "{0:d}")%>

        </td>

    </tr>

    </ItemTemplate>

</asp:Repeater>

</form>



-- Code Behind --

Private Sub BindRepeater()



	Dim ctl As New myQuestionCategoryController



	Dim arr As ArrayList = ctl.myQuestionCategoryGetByModules(Me.MainModuleID, False, False)



	Me.rpCategory.DataSource = arr

	Me.rpCategory.DataBind()



End Sub

Open in new window

0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 50 total points
Comment Utility
0
 
LVL 1

Author Closing Comment

by:Craig Lambie
Comment Utility
Thanks, worked a charm.  Sorry for delay, was sick as yesterday.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now