Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Row_DataBound or Row_Created event in GridView

Tags:

c#

asp.net

I have doubt about the Row_DataBound and Row_Created events :

  1. What is the difference between Row_DataBound and Row_Created events?

  2. What are the parameters for choosing between these two events?

like image 353
santosh singh Avatar asked Jun 10 '11 17:06

santosh singh


1 Answers

RowCreated occurs after a row and all of its child controls are created.

RowDataBound occurs after the row (and its controls) are databound, i.e. populated with the data values.

The answer about which to use really depends on if you need the databound values or not. e.g. If you wanted to change the background color of your row based the value of one of your fields, then you would have to use the RowDataBound event. If your logic doesn't depend on the data, then I don't think it matters which event you use.

An example of where you would have to use RowCreated is if you had a drop down list in your row that would need to be popluated with values before the selected value was databound.

like image 98
Jim Harte Avatar answered Sep 20 '22 01:09

Jim Harte