My Opera is closing 3rd of March

knowledge, skill, experience ... about IT, computer, programming ...

Kiến thức tạo nên sức mạnh, năng lực đạp đổ bằng cấp...!

Formatting Grid View - Change appearance of rows

If you are seeing this section and do not see download links, this means that you are not logged into our site. If you already are a member, click on the login link and login into site and come back to this page for downloading the control files. If you are not a member, click on registration link to become a Winista member and download the control for free.




In DataGrid and GridView controls there is a property that lets you specify specify style for alternate rows. For DataGrid this property is AlternatingItemStyle and for GridView it is AlternatingRowStyle. For one of my reports the requirement was slightly different. The client wanted to alter behavior of every third row in the view. Thats where GirdView's RowCreated event came in very handy. You simply subscribe to this event and your event handler gets called for every row creation. In this event you can check the properties of Row getting created and you can alter the rendering property. Following code shows how I was able to set the background color of every third row in GridView.

protected void OnRowCreated(object sender, GridViewRowEventArgs e)
{
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
        if (((e.Row.RowIndex+1) % 3) == 0)
        {
            e.Row.BackColor = System.Drawing.Color.Snow;
        }
     }
}

5 điều Google “chào thua” Yahoo! SearchHow to shown format number like this {###,###.##} in GridView?

Write a comment

New comments have been disabled for this post.

February 2014
S M T W T F S
January 2014March 2014
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28