Yes, I know. I have not written anything in a whileeeee! After I got married and graduated from school, have not had much time for myself.

But today at work, after an hour of debugging an ASP.NET application and trying to find an answer why the GridViewRow.RowState property was acting wierd, I learned something new and I wanted to share it. I learned that the RowState property is actually checking the value using bit logic. I had not used bitwise operator since school and found interesting that I finally find an use for it. 

My problem was that I wanted to modify all the rows but the ones marked as RowState.DataControlRowState.Edit in the RowDataBoud event and at first I was doing it wrong:

 If e.Row.RowType = DataControlRowType.DataRow And (e.Row.RowState <> DataControlRowState.Edit) Then ...

It looked fine to me, but it didn't work.  An that's how I discovered I had to use bit logic because that is how the RowState property stores its values. The correct way to do this is:

 If e.Row.RowType = DataControlRowType.DataRow And ((e.Row.RowState And DataControlRowState.Edit) <> DataControlRowState.Edit) Then ...

By using the AND bitwise operator you are actually checking is the value is in the "bucket" (this term is well explained in the link I provide below) and then comparing the bit value. It's pretty easy once you understand the concept. And the concept was well explained in this article.

http://weblogs.asp.net/alessandro/archive/2007/10/02/one-bit-masks-for-access-control-setting-permissions-in-your-asp-net-applications.aspx

Hope it helps somebody.