473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Repeater control and Eval()

Hi,

I was doing some repeater control tests last day, and there was one thing i
couldn't figure out.
Please look at the following sample code:

In the cs file:
string[] s = new string[] { "1", "2" };
repeatertest.DataSource = s;
repeatertest.DataBind();

In the aspx file:
<asp:Repeater ID="repeatertest" runat="server">
<ItemTemplate>
<tr>
<td>
<%#Eval(**** What to write here ****) %>
</tr>
</ItemTemplate>
</asp:Repeater>

I want the Repeater to write out the contents from property "s", but i don't
know how to write the Eval() method.

BR
Peter Larsen
Aug 25 '08 #1
7 5480
On Aug 25, 12:57*pm, "Peter Larsen [CPH]"
<PeterLar...@community.nospamwrote:
Hi,

I was doing some repeater control tests last day, and there was one thingi
couldn't figure out.
Please look at the following sample code:

In the cs file:
* * * * string[] s = new string[] { "1", "2" };
* * * * repeatertest.DataSource = s;
* * * * repeatertest.DataBind();

In the aspx file:
* * * * <asp:Repeater ID="repeatertest" runat="server">
* * * * * * <ItemTemplate>
* * * * * * * * <tr>
* * * * * * * * * * <td>
* * * * * * * * * * * * <%#Eval(**** *What to write here *****) %>
* * * * * * * * </tr>
* * * * * * </ItemTemplate>
* * * * </asp:Repeater>

I want the Repeater to write out the contents from property "s", but i don't
know how to write the Eval() method.

BR
Peter Larsen
I am not quite sure but try this: <%# (string)Container.DataItem %,
this should work, at least I have used this way in past but i bound to
may be ArrayList or Table.
Aug 25 '08 #2
Hi Alex,

Thank you for your comment - unfortunately it doesn't work with string
array.
It does know that the first item is "1", but it is not delivered in away
that is acceptable for #Eval.

BR
Peter
"AleXmanFree" <al*********@gmail.comwrote in message
news:5f**********************************@25g2000h sx.googlegroups.com...
On Aug 25, 12:57 pm, "Peter Larsen [CPH]"

I am not quite sure but try this: <%# (string)Container.DataItem %,
this should work, at least I have used this way in past but i bound to
may be ArrayList or Table.
Aug 25 '08 #3
you use eval when you wany to use refection to access properties of the
dataitem. in ytour case the dataitem is a string and has no usefull
properties, so you should not use eval. follow the above suggestion or if you
don't want a cast:

<%# Container.DataItem.ToString() %>
-- bruce (sqlwork.com)
"Peter Larsen [CPH]" wrote:
Hi Alex,

Thank you for your comment - unfortunately it doesn't work with string
array.
It does know that the first item is "1", but it is not delivered in away
that is acceptable for #Eval.

BR
Peter
"AleXmanFree" <al*********@gmail.comwrote in message
news:5f**********************************@25g2000h sx.googlegroups.com...
On Aug 25, 12:57 pm, "Peter Larsen [CPH]"

I am not quite sure but try this: <%# (string)Container.DataItem %,
this should work, at least I have used this way in past but i bound to
may be ArrayList or Table.
Aug 25 '08 #4
Hi Peter,

Since the item in the datasource is not a complex class that has column
properties, you should directly reference it via "Container.DataItem". Here
is a complete example:

=========aspx page============
<form id="form1" runat="server">
<div>

<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<hr />
item: <%# Container.DataItem.ToString() %>
</ItemTemplate>
</asp:Repeater>

</div>
</form>
=====================

==========code behind=============
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] items = new string[] { "aa", "bb", "cc", "dd" };
Repeater1.DataSource = items;
Repeater1.DataBind();
}
}
====================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter Larsen [CPH]" <Pe*********@community.nospam>
References: <Or**************@TK2MSFTNGP06.phx.gbl>
<5f**********************************@25g2000hsx.g ooglegroups.com>
>Subject: Re: Repeater control and Eval()
Date: Mon, 25 Aug 2008 12:46:02 +0200
>
Hi Alex,

Thank you for your comment - unfortunately it doesn't work with string
array.
It does know that the first item is "1", but it is not delivered in away
that is acceptable for #Eval.

BR
Peter
"AleXmanFree" <al*********@gmail.comwrote in message
news:5f**********************************@25g2000 hsx.googlegroups.com...
On Aug 25, 12:57 pm, "Peter Larsen [CPH]"

I am not quite sure but try this: <%# (string)Container.DataItem %,
this should work, at least I have used this way in past but i bound to
may be ArrayList or Table.
Aug 26 '08 #5
Hi Bruce,

Thanks for the answer - of course, this is the way to do it :-)

BR
Peter

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:74**********************************@microsof t.com...
you use eval when you wany to use refection to access properties of the
dataitem. in ytour case the dataitem is a string and has no usefull
properties, so you should not use eval. follow the above suggestion or if
you
don't want a cast:

<%# Container.DataItem.ToString() %>


Aug 26 '08 #6
Hi Steven,

Thanks for the code sample - as always copy/pastable ready :-)
I appreciate your effort to make it as easy as possible.

BR
Peter

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:qK**************@TK2MSFTNGHUB02.phx.gbl...
Hi Peter,

Since the item in the datasource is not a complex class that has column
properties, you should directly reference it via "Container.DataItem".
Here
is a complete example:

Aug 26 '08 #7
My pleasure:)

Thanks for your posting here.

have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
--------------------
>From: "Peter Larsen [CPH]" <Pe*********@community.nospam>
References: <Or**************@TK2MSFTNGP06.phx.gbl>
<5f**********************************@25g2000hsx.g ooglegroups.com>
<Ow**************@TK2MSFTNGP02.phx.gbl>
<qK**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: Repeater control and Eval()
Date: Tue, 26 Aug 2008 10:42:32 +0200
>Hi Steven,

Thanks for the code sample - as always copy/pastable ready :-)
I appreciate your effort to make it as easy as possible.

BR
Peter

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:qK**************@TK2MSFTNGHUB02.phx.gbl...
>Hi Peter,

Since the item in the datasource is not a complex class that has column
properties, you should directly reference it via "Container.DataItem".
Here
is a complete example:


Aug 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gastin | last post by:
I am digesting a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
4
by: Bernie V | last post by:
Hi group, Is it possible to use a condition in a repeater control ? I 'd like to use a condition to create this <a href='<%#DataBinder.Eval(Container.DataItem,"nieuwsid")%>.aspx'> part of the...
5
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below...
2
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
1
by: Christiaan Nieuwlaat | last post by:
Hi everyone, Could you please help me with this? I need to create a table in which resultdata from a sql server table can be shown and/or edited by using controls, for instance the radiobutton....
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
3
by: Ben Dewey | last post by:
Hey everyone, I have a wierd issue i can't seem to find out whats going on. I have a Control for a Shopping Cart Merchant Page called OrderStatus.ascx Inside that control there is a Repeater...
3
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
4
by: John Kotuby | last post by:
Hi all, I am using a Repeater in conjunction with a SQLDatasource and SQL Server. One of the controls in the repeater is a HyperlLink as follows: <asp:HyperLink...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.