According to the VS 2008 properties for a GridView:
If I want to manipulate the text in a header column, does it matter if I use the DataBound or RowDataBound because I can always just check the e.Row.RowType. Is there an actual difference besides the obvious?
RowCommand - when you add edit,select,delete etc.. command to gridview row, and you want to intercept this command handling, then use this method. RowDataBound: When the Data bind to the grid, (say for example a datatable), Each ROW of these data bind to the grid, this event get fired.
The RowDataBound event is raised when a data row (represented by a GridViewRow object) is bound to data in the GridView control. This enables you to provide an event-handling method that performs a custom routine, such as modifying the values of the data bound to the row, whenever this event occurs.
Get cell value of GridView in RowCommand event in ASP.Net The row index can be easily determined using the CommandArgument property of GridViewCommandEventArgs object and using the row index, the GridView Row is referenced. Finally using the reference of the GridView Row, the values from the cells are fetched.
DataBound happens after all RowDataBound events are done firing, and therefore only fires once for the control. If you only have one thing to do, put it in the DataBound method. If it's something that needs to happen on an arbitrary row, do it in RowDataBound.
You're looking to customize something within a single row. I'd use RowDataBound.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With