• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2862
  • Last Modified:

why do I need to check 'e.Row.RowType == DataControlRowType.DataRow'?

Hi
I have a GridView control and I have following RowdataBound event.  I understand that this event is rased for each row, but I don't understand the
'if (e.Row.RowType == DataControlRowType.DataRow)' part.
I guess 'e.Row.RowType' means Current row's row type, correct?  
As I know, 'DataControlrowType.DataRow' means a data row of data control.
What does that mean if these two are equal???

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
                //Get the price for this row.
                // if price > $50, change the background color.
          }
 }
0
IzzyTwinkly
Asked:
IzzyTwinkly
3 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
because the even is also raised for header and footer / grouping rows.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
even => event
0
 
Snarf0001Commented:
The rowtype could also be a header or footer row, this is ensuring that you don't try to run calculations on headers for example.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Snarf0001Commented:
Lol, what he said
0
 
NazoUKCommented:
You are testing to make sure that the row is a data row, not the header, footer etc.

In your example, you are testing the price of the individual row, it doesn't make sense to do this for the header or footer, which is why you do the test.
0
 
IzzyTwinklyAuthor Commented:
thank u all~~~
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now