?
Solved

Repeater Row BgColor odd even color

Posted on 2006-11-10
2
Medium Priority
?
473 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
vbandaru earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

762 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