Grid formatting

Posted on 2004-11-02
Last Modified: 2010-04-15
Hi Experts,

I have DataGrid that is bound by : DataGrid1.DataBind(); command
The question is how to make odd rows white and even rows red ?
Is there built-in method for this ?

Question by:fpoyavo
    LVL 3

    Expert Comment

    Yeah it's the AlternateItemTemplate, just set its color to whatever you want.
    LVL 3

    Expert Comment

    Sorry it's: AlternatingItemStyle

    <AlternatingItemStyle BackColor="#66FFFF"></AlternatingItemStyle>

    Good Luck
    LVL 3

    Expert Comment

    Here's a bigger example:

    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 116; LEFT: 624px; POSITION: absolute; TOP: 136px"
    <AlternatingItemStyle BackColor="#00FFFF"></AlternatingItemStyle>
    LVL 18

    Accepted Solution

    Are you using VS .Net? if yes then you can do it one of the following way:

    Right Click Your DataGrid --> Property Builder --> Format -->  Expand Items
      --> Modify the Alternating Item

    2) Use AutoFormat!
    Right Click Your DataGrid --> AutoFormat --> Select any...

    LVL 3

    Expert Comment

    Ahh! Beginners! That's too bad, but it is Experts Exchange, at least the I showed you can be applied everywhere else including VS.NET

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT Security CISA, CISSP & CISM Certification

    Master the advanced techniques required to protect network resources from external threats with the IT Cyber Security bundle. Built around industry best-practice guidelines, the IT Cyber Security bundle consists of three in-depth courses.

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    846 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

    3 Experts available now in Live!

    Get 1:1 Help Now