473,804 Members | 2,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="R epDS">
<HeaderTempla te ><table cellpadding="5" cellspacing="2" >
<tr class="TableCap tions">
<td><b>UID</b></td>
<td><b>Suppli er 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"><a sp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageB utton ID="IBSupplierS KU"
runat="server" ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBLinkedSKU " runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBShortDesc ription"
runat="server" ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</ItemTemplate>
<AlternatingIte mTemplate>
<tr class="RowStyle ">
<td align="left" valign="top"><a sp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageB utton ID="IBSupplierS KU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBLinkedSKU " runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBShortDesc ription" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBSKUDescri ption" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</AlternatingItem Template>
</asp:Repeater>
<asp:SqlDataSou rce ID="repDS" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:DBConn %>"
SelectCommand=" SELECT [UID], [SupplierSKUCode], [LinkedSKU],
[Name], [ShortDescriptio n], [SKUDescription] FROM [Import_Lines]">
</asp:SqlDataSour ce>

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 2298
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*********@pr ivacy.netwrote in message
news:5e******** *****@mid.indiv idual.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="R epDS">
<HeaderTempla te ><table cellpadding="5" cellspacing="2" >
<tr class="TableCap tions">
<td><b>UID</b></td>
<td><b>Suppli er 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"><a sp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageB utton ID="IBSupplierS KU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBLinkedSKU " runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBShortDesc ription"
runat="server" ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</ItemTemplate>
<AlternatingIte mTemplate>
<tr class="RowStyle ">
<td align="left" valign="top"><a sp:Label ID="lblName"
runat="server" /></td>
<td><asp:ImageB utton ID="IBSupplierS KU" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBLinkedSKU " runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBName" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBShortDesc ription" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
<td><asp:ImageB utton ID="IBSKUDescri ption" runat="server"
ImageUrl="~/imgs/cross.gif" /></td>
</tr>
</AlternatingItem Template>
</asp:Repeater>
<asp:SqlDataSou rce ID="repDS" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:DBConn %>"
SelectCommand=" SELECT [UID], [SupplierSKUCode], [LinkedSKU], [Name],
[ShortDescriptio n], [SKUDescription] FROM [Import_Lines]">
</asp:SqlDataSour ce>

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
1773
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 nested within the first repeater. If it is nested within the first repeater, I don't get any data. If I put the second repeater as a separate repeater, not nested, it works fine. Here's my actual code, showing data pulled from the array within a...
2
3304
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 reference not set to an instance of an object". This error message commonly occurs when a server control is incorrecly declared, so naturally I have double checked this. To test this, I moved the aspx code for the DataGrid ('myNestedDataGrid')...
2
2134
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 function. My objects aren't null, my ItemDataBound() method is being called, and as you can see I have verified that I have data. Yet, the repeater does not appear in the final HTML, and what's more, after
8
2919
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"> <HeaderTemplate><table> </HeaderTemplate> <ItemTemplate>
3
4173
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 ItemDataBound event but I think it is too late. What am I doing wrong? Thanks Shimon.
2
1915
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 to work just fine, as long as it's not nested within the first repeater. If it is nested within the first repeater, I don't get any data. If I put the second repeater as a separate repeater, not nested, it works fine. Here's my actual code,...
0
4097
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 that my second repeater has the following error, System.NullReferenceException: Object reference not set to an instance of an object. When I put a watch on I can see my second repeater is not being created because it is equal to "Nothing". I can...
7
3010
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 attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
1
7134
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 following the www.asp.net data access tutorials to create a DAL and BLL to connect my web site (a simple real estate property search web site) to my database (Sql Express 2005).
2
1877
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 will not render the controls in ItemTemplate and AlternateItemTemplate. ItemDataBound event is fired appropriately, just the rendering seems to be messed up. The real funny part about this problem, is that it happens only on a specific website of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.