Solved

Repeater Row BgColor odd even color

Posted on 2006-11-10
2
465 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now