Solved

Repeater Row BgColor odd even color

Posted on 2006-11-10
2
469 Views
Last Modified: 2012-05-05
This should be pretty simple so here it is.

Just like with the Gridview you can make it have every other row a different color. This makes for a cleaner looking table and easier to read one at that.

Here is the code that I have (obviously not working.

 

Codebehind

protected void RowColor(object sender, string RowNum)

{


if (RowNum % 2 == 0)

{

return "blue";

}

else

{

return "red";

}

}

 

 

the ASPX

<ItemTemplate>

<tr bgcolor=<%# RowColor(Eval("answerid")) %>>

 

the current errors I get is

Error 1 No overload for method 'RowColor' takes '1' arguments C:\Documents and Settings\Scott\My Documents\MSDN\Learn Visual Web Developer 2005 Express Edition-C#-Lesson 13\Snapshot5\QuizCS\questions.aspx 113


Error 2 Operator '%' cannot be applied to operands of type 'string' and 'int' C:\Documents and Settings\Scott\My Documents\MSDN\Learn Visual Web Developer 2005 Express Edition-C#-Lesson 13\Snapshot5\QuizCS\questions.aspx.cs 61


Error 3 Since 'questions.RowColor(object, string)' returns void, a return keyword must not be followed by an object expression C:\Documents and Settings\Scott\My Documents\MSDN\Learn Visual Web Developer 2005 Express Edition-C#-Lesson 13\Snapshot5\QuizCS\questions.aspx.cs 63


Error 4 Since 'questions.RowColor(object, string)' returns void, a return keyword must not be followed by an object expression C:\Documents and Settings\Scott\My Documents\MSDN\Learn Visual Web Developer 2005 Express Edition-C#-Lesson 13\Snapshot5\QuizCS\questions.aspx.cs 67


Thank you in advance
0
Comment
Question by:Scripter25
2 Comments
 
LVL 7

Accepted Solution

by:
vbandaru earned 500 total points
ID: 17919538
Obvisuoly one problem I see is You have declared your function to return void but is returning "Red" or "Blue".

I need more information on the type of control you are using.

0
 

Author Comment

by:Scripter25
ID: 17920072
Ok yes you are correct I did do the overall codebehind incorrectly. the overall answer though I found to be this

ItemTemplate       Defines the content and layout of items within the list. Required.

AlternatingItemTemplate             If defined, the AlternatingItemTemplate determines the content and layout of alternating items. If not defined, ItemTemplate is used.

You can set the color values on that and that will do all the work for you.

Now though seeing as how you did answer the question somewhat I do want to provide you with the points but I in order for that can you give me an example of code that would take in a value of integer and return a string value?

this would help alot
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.net Fit 3 divs on screen side by side 3 39
encoding an href string 2 24
ASP.NET (VB) return a record 2 35
asp.net open new page without popup blocker 8 18
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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