?
Solved

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

Posted on 2010-01-09
6
Medium Priority
?
2,653 Views
Last Modified: 2013-12-17
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
Comment
Question by:IzzyTwinkly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1600 total points
ID: 26274718
because the even is also raised for header and footer / grouping rows.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 26274720
even => event
0
 
LVL 23

Assisted Solution

by:Snarf0001
Snarf0001 earned 200 total points
ID: 26274725
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
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 
LVL 23

Expert Comment

by:Snarf0001
ID: 26274731
Lol, what he said
0
 
LVL 15

Assisted Solution

by:NazoUK
NazoUK earned 200 total points
ID: 26274764
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
 

Author Comment

by:IzzyTwinkly
ID: 26275570
thank u all~~~
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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