[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how do I change to row color every odd number row with repeater item?

Posted on 2009-03-30
3
Medium Priority
?
396 Views
Last Modified: 2012-05-06
I need to change the rows bg color every odd color in a repeater item. any help would be appreciative.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        conn = New MySqlConnection(ConfigurationManager.AppSettings("MyConnectionString"))
        conn.Open()
 
        strSql = "Select * from login"
        cmd = New MySqlCommand(strSql, conn)
        da = New MySqlDataAdapter(cmd)
        ds = New DataSet()
        da.Fill(ds)
 
        Me.rptLogin.DataSource = ds.Tables(0)
        Me.rptLogin.DataBind()
 
        For Each item As RepeaterItem In rptLogin.Items
 
        Next
end sub

Open in new window

0
Comment
Question by:bschave2
[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
3 Comments
 
LVL 9

Accepted Solution

by:
cdaly33 earned 1500 total points
ID: 24021677
There is a template called AlternatingItemTemplate in Repeaters that you could use to set the background color.

Or... I'd try doing it in the repeaters item data bound event. See code.
  Protected Sub rpt_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt.ItemDataBound
    If e.Item.ItemType = ListItemType.AlternatingItem Then
      DirectCast(e.Item.FindControl("Row"), HtmlTableRow).BgColor = "silver"
    End If
  End Sub

Open in new window

0
 

Author Comment

by:bschave2
ID: 24030261
how would I call this sub?
0
 

Author Comment

by:bschave2
ID: 24030311
getting this error: Object reference not set to an instance of an object.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

650 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