Solved

Explain how DataRepeater Container gets data from DataSource

Posted on 2010-11-13
4
1,021 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

862 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

27 Experts available now in Live!

Get 1:1 Help Now