Row_DataBound or Row_Created event in GridView

I doubt the Row_DataBound and Row_Created :

  • What is the difference between Row_DataBound and Row_Created ?

  • What are the options for choosing between these two events?

+6
source share
1 answer

RowCreated happens after the line, and all its child controls are created.

RowDataBound occurs after the row (and its controls) is a data binding, i.e. populated with data values.

The answer about what to use really depends on whether data values ​​are needed or not. for example, if you want to change the background color of your row based on the value of one of your fields, you will have to use the RowDataBound event. If your logic is data independent, then I don’t think it matters which event you use.

An example of where you should use RowCreated is that if your line had a drop-down list that should be populated with values ​​before the selected value is bound to the database.

+8
source

Source: https://habr.com/ru/post/890243/


All Articles