Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it matter if I use RowDataBound or DataBound for a GridView

According to the VS 2008 properties for a GridView:

  • DataBound fires after the control has been databound.
  • RowDataBound fires after a row has been databound.

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?

like image 385
Xaisoft Avatar asked Nov 13 '08 21:11

Xaisoft


People also ask

What is the difference between RowDataBound and RowCommand?

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.

What is RowDataBound event in GridView?

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.

How can get GridView column value in RowDataBound?

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.


2 Answers

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.

like image 129
Robert C. Barth Avatar answered Sep 23 '22 04:09

Robert C. Barth


You're looking to customize something within a single row. I'd use RowDataBound.

like image 32
Kon Avatar answered Sep 21 '22 04:09

Kon