Solved

Explain how DataRepeater Container gets data from DataSource

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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