?
Solved

Explain how DataRepeater Container gets data from DataSource

Posted on 2010-11-13
4
Medium Priority
?
1,033 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 800 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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