473,385 Members | 1,780 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,385 software developers and data experts.

How to skip some items of a repeater

Hello,
I would like to skip the display of some items of a repeater. I think I
need to do something like this:
<asp:Repeater ...>
<ItemTemplate>
<% if (a == b) { %>
...
<% } %>
</ItemTemplate>
</asp:Repeater>

But I can't find out the exact syntax, or if there is a better way to do
that.

Thank you
Julien
Sep 14 '06 #1
3 11127
Julien,

In the ItemDataBound event of the repeator you could mark the item as not
being visible:

protected void Repeater1_ItemDataBound(
object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
string A = (string)((DataRowView)e.Item.DataItem).Row["A"];
string B = (string)((DataRowView)e.Item.DataItem).Row["B"];

if (A == B)
{
e.Item.Visible = false;
}
}
}
Would that work for you?

Regards,

Rob

"Julien Sobrier" <ju****@sobrier.netwrote in message
news:45***********************@news.sonic.net...
Hello,
I would like to skip the display of some items of a repeater. I think I
need to do something like this:
<asp:Repeater ...>
<ItemTemplate>
<% if (a == b) { %>
...
<% } %>
</ItemTemplate>
</asp:Repeater>

But I can't find out the exact syntax, or if there is a better way to do
that.

Thank you
Julien

Sep 14 '06 #2
Thank you.

In my case, I have HTML and C# code inside the item::

<ItemTemplate>
<p><%# Convert.ToString( DataBinder.Eval(Container.DataItem, "xxxxxx")) %>
<asp:DropDownList ID="ListValues" runat="server" Visible="false">
</asp:DropDownList>
<asp:TextBox ID="FreeText" runat="server" Visible="false">
</asp:TextBox><br />
<span style="font-style:italic"><%# Convert.ToString(
DataBinder.Eval(Container.DataItem, "yyyy")) %></span></p>
</ItemTemplate>

Julien

Rob MacFadyen wrote:
Julien,

In the ItemDataBound event of the repeator you could mark the item as not
being visible:

protected void Repeater1_ItemDataBound(
object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
string A = (string)((DataRowView)e.Item.DataItem).Row["A"];
string B = (string)((DataRowView)e.Item.DataItem).Row["B"];

if (A == B)
{
e.Item.Visible = false;
}
}
}
Would that work for you?

Regards,

Rob

"Julien Sobrier" <ju****@sobrier.netwrote in message
news:45***********************@news.sonic.net...
>Hello,
I would like to skip the display of some items of a repeater. I think I
need to do something like this:
<asp:Repeater ...>
<ItemTemplate>
<% if (a == b) { %>
...
<% } %>
</ItemTemplate>
</asp:Repeater>

But I can't find out the exact syntax, or if there is a better way to do
that.

Thank you
Julien

Sep 15 '06 #3
hi Julien,
you could always iterate over each row of the datasource before
data-binding, and remove the rows directly. i can't imagine this would be
any slower than alternative approaches.

good luck
tim
Sep 16 '06 #4

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

Similar topics

24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
1
by: Mark Fox | last post by:
Hello, I have a repeater and in each itemtemplate I have a radiobuttonlist. I am attempting to figure out how on postback I could iterate through the rows displayed by the repeater and for...
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
2
by: Antoine | last post by:
I would like to construct my own list of items in a grid/ table/ item list layout but I have a problem. I want to add a sort of index row based on time, such as there might be blank values. Sure...
1
by: Alan Silver | last post by:
Hello, I have a page in which I'm trying to give the user the chance to manipulate a list of items. These are the price variations for a product, so each item consists of a name (eg, small,...
2
by: Lloyd Sheen | last post by:
I have a repeater that will have linkbuttons. I have googled much but cannot find a solution to the following. Since the items are dynamic I need to be able to attach handlers to the...
2
by: HockeyFan | last post by:
Yesterday, I posted a question dealing with an issue of trying to reference (from javascript on the client side) an item within a Repeater. My code was hard-coded to use the actual ClientId, but...
2
by: Newbe developer | last post by:
I have a question how I can evaluate the item values. I want to know which radiobutton is true in order to save the value it represents. the code is this: <asp:Repeater id="futuregames"...
4
by: adiel_g | last post by:
I am trying to loop through a repeater to retrieve a dataitem field but am getting a NullReferenceException. I can find a checkbox control but cannot find a dataitem field. Here is the code that...
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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.