Form designer: How to customize the OnRowDataBound, DataBound, OnDataBound events

The ASP.NET form generated by the Form Designer already had defined .NET code for the OnRowDataBound, DataBound, and OnDataBound events.

For GridViews:

  • protected void GridView_DataBound(object sender, EventArgs e)

  • protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)

For DropDownLists and ListBoxes:

  • protected void List_OnDataBound(object sender, EventArgs e)

You cannot overwrite this code, but you can add new event handlers.

Example

DropDownListID.DataBound += new EventHandler(DropDownListID_OnDataBound);