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

Repeater Problem

Hi everyone, I hope you all had a great weekend.
I have a problem, and I am really not sur eon how I should address it; I
have a repeater control, which is bound to a SqlDataSource, however
within the repeater control are a number of ImageButtons, and basically
if the Data Item is empty of NULL then I wish the image on the button to
be "cross.gif" otherwise I would like it to be "tick.gif".

As I said before I really have never came accross anything of the like
before, so I am totally stumped. Here is my current code:

<asp:Repeater ID="repItems" runat="server" DataSourceID="RepDS">
<HeaderTemplate ><table cellpadding="5" cellspacing="2" >
<tr class="TableCaptions">
<td><b>UID</b></td>
<td><b>Supplier SKU</b></td>
<td><b>Linked SKU</b></td>
<td><b>Name</b></td>
<td><b>SD</b></td>
<td><b>SKD</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="RowStyle">
<td align="left" valign="top"><asp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageButton ID="IBSupplierSKU"
runat="server" ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBLinkedSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBShortDescription"
runat="server" ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="RowStyle">
<td align="left" valign="top"><asp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageButton ID="IBSupplierSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBLinkedSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBShortDescription" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBSKUDescription" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</AlternatingItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="repDS" runat="server" ConnectionString="<%$
ConnectionStrings:DBConn %>"
SelectCommand="SELECT [UID], [SupplierSKUCode], [LinkedSKU],
[Name], [ShortDescription], [SKUDescription] FROM [Import_Lines]">
</asp:SqlDataSource>

If anyone can help, i'll gladly buy you virtual beer for the rest of
your life.

Kind Regards
Mick
Jun 25 '07 #1
1 2266
The most flexible way is to handle the ItemDataBound event. The event fires
for every repeater row (item) as it gets bound. You need to filter out items
that you don't want to handle, like header, footer, separator. For every
data item you get full access to the control in ItemTemplate and to the
DataItem. You can check and set any properties.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mick Walker" <Mi*********@privacy.netwrote in message
news:5e*************@mid.individual.net...
Hi everyone, I hope you all had a great weekend.
I have a problem, and I am really not sur eon how I should address it; I
have a repeater control, which is bound to a SqlDataSource, however within
the repeater control are a number of ImageButtons, and basically if the
Data Item is empty of NULL then I wish the image on the button to be
"cross.gif" otherwise I would like it to be "tick.gif".

As I said before I really have never came accross anything of the like
before, so I am totally stumped. Here is my current code:

<asp:Repeater ID="repItems" runat="server" DataSourceID="RepDS">
<HeaderTemplate ><table cellpadding="5" cellspacing="2" >
<tr class="TableCaptions">
<td><b>UID</b></td>
<td><b>Supplier SKU</b></td>
<td><b>Linked SKU</b></td>
<td><b>Name</b></td>
<td><b>SD</b></td>
<td><b>SKD</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="RowStyle">
<td align="left" valign="top"><asp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageButton ID="IBSupplierSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBLinkedSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBShortDescription"
runat="server" ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="RowStyle">
<td align="left" valign="top"><asp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageButton ID="IBSupplierSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBLinkedSKU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBShortDescription" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageButton ID="IBSKUDescription" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</AlternatingItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="repDS" runat="server" ConnectionString="<%$
ConnectionStrings:DBConn %>"
SelectCommand="SELECT [UID], [SupplierSKUCode], [LinkedSKU], [Name],
[ShortDescription], [SKUDescription] FROM [Import_Lines]">
</asp:SqlDataSource>

If anyone can help, i'll gladly buy you virtual beer for the rest of your
life.

Kind Regards
Mick

Jun 25 '07 #2

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

Similar topics

0
by: mark | last post by:
My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater to work just fine, as long as it's not...
2
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
2
by: Colin Nicholls | last post by:
Platform: ASP.NET 1.1 I have a repeater nested inside another repeater. My outer repeater is looping fine. I am manually binding the inner repeater to a DataReader obtained from another...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
3
by: Shimon Sim | last post by:
I put linkbutton in a repeater header. I attached event handler in makeup as onclick="btnSort_Click". Made btnSort_Click method public. It doesn't fire if I click on it. I tried to attach it in...
2
by: mark | last post by:
(not sure if this is the correct group) My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
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...
1
by: jazzart | last post by:
Hi there, I'm fairly new to programming with Asp.Net 2.0 so I'm finding myself regularly fumbling around in the dark a bit, so to speak. I'm currently using Visual Web Developer and have been...
2
by: Hong | last post by:
Hi, I have been scratching my head over this problem for hours, the repeater control I am using would only render the controls specified in HeaderTemplate and FooterTemplate, but the repeater...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.