简体   繁体   中英

Row_DataBound or Row_Created event in GridView

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?

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

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

The answer about which to use really depends on if you need the databound values or not. eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM