Solved

Explain how DataRepeater Container gets data from DataSource

Posted on 2010-11-13
4
1,024 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
ID: 34130655
What version of .Net are you using?
0
 
LVL 16

Accepted Solution

by:
BurnieP earned 200 total points
ID: 34131005
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
ID: 34131200
0
 
LVL 1

Author Closing Comment

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

775 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