Solved

Repeater Row BgColor odd even color

Posted on 2006-11-10
2
471 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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