Solved

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

Posted on 2009-03-30
3
384 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
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
cdaly33 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

15 Experts available now in Live!

Get 1:1 Help Now